Class: Generators::Simple
- Defined in:
- lib/toschas/filterable/generators/simple.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Generators::Base
Instance Method Details
#generate ⇒ Object
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/toschas/filterable/generators/simple.rb', line 3 def generate filters.each do |filter| model.define_singleton_method( "by_#{filter}", ->(value) { send(:where, { filter => value }) } ) generate_range_filter(filter) if table_loaded? && range_filter?(filter) end end |