Module: ActsAsOrdinalized::ClassMethods
- Defined in:
- lib/acts_as_ordinalized.rb
Overview
this acts_as extension add ordinal numbers to active record collections each collection gets new ordinal numbers starting from one paginated results should also get correct ordinal numbers on subsequent pages
Instance Method Summary collapse
-
#acts_as_ordinalized(options = {}) ⇒ Object
Configuration options are:.
Instance Method Details
#acts_as_ordinalized(options = {}) ⇒ Object
Configuration options are:
-
wrapped_methods
- specifies additional class methods that should be wrapped with functionality (basic are find and paginate)
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/acts_as_ordinalized.rb', line 13 def acts_as_ordinalized( = {}) attr_accessor :ordinal_number wrapped_methods = ([:paginate, :find] << [:wrapped_methods]).flatten.compact #wrap various find methods with adding ordinal numbers to all returned models wrapped_methods.each do |method_name| class_eval <<-EOV def self.#{method_name}(*args) ActsAsOrdinalized.ordinalize(super(*args)) end EOV end end |