880cbab435f00197613c9cc2065b4f5a

I added these so I could refer to Report::HITS in the API. There will be more than just hits and uniques, and I'm wondering if there's a shorter way to declare all this, or a more idiomatic way.

1
2
3
4
5
6
class Report < ActiveRecord::Base
  belongs_to :reportable, :polymorphic => true
  
  HITS = 'hits'
  UNIQUES = 'uniques'
end

Refactorings

No refactoring yet !

A8d3f35baafdaea851914b17dae9e1fc

Adam

August 14, 2008, August 14, 2008 20:13, permalink

2 ratings. Login to rate!
1
2
3
class Report < ActiveRecord::Base
  %w[hits uniques].each { |const| const_set(const.upcase, const) }
end

Your refactoring





Format Copy from initial code

or Cancel