Module: RestApiGenerator::Filterable::ClassMethods
- Defined in:
- lib/rest_api_generator/filterable.rb
Instance Attribute Summary collapse
-
#filter_scopes ⇒ Object
readonly
Returns the value of attribute filter_scopes.
Instance Method Summary collapse
Instance Attribute Details
#filter_scopes ⇒ Object (readonly)
Returns the value of attribute filter_scopes.
14 15 16 |
# File 'lib/rest_api_generator/filterable.rb', line 14 def filter_scopes @filter_scopes end |
Instance Method Details
#filter_resource(params) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/rest_api_generator/filterable.rb', line 21 def filter_resource(params) results = where(nil) params.each do |key, value| results = results.public_send(:"filter_by_#{key}", value) if value.present? end results end |
#filter_scope(name, *args) ⇒ Object
16 17 18 19 |
# File 'lib/rest_api_generator/filterable.rb', line 16 def filter_scope(name, *args) scope name, *args @filter_scopes << name.to_s.gsub("filter_by_", "").to_sym end |