Class: Mongoid::Orderable::Generators::Helpers
- Defined in:
- lib/mongoid/orderable/generators/helpers.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Mongoid::Orderable::Generators::Base
Instance Method Details
#generate ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/mongoid/orderable/generators/helpers.rb', line 7 def generate self_class = klass klass.class_eval <<~KLASS, __FILE__, __LINE__ + 1 def orderable_top(field = nil) field ||= default_orderable_field #{self_class}.orderable_configs[field][:base] end def orderable_field(field = nil) field ||= default_orderable_field #{self_class}.orderable_configs[field][:field] end def orderable_if(field) #{self_class}.orderable_configs[field][:if] end def orderable_unless(field) #{self_class}.orderable_configs[field][:unless] end KLASS generate_method(:orderable_inherited_class) do self_class.orderable_configs.any? {|_field, conf| conf[:inherited] } ? self_class : self.class end end |