Module: Queryable::Chainable::ClassMethods
- Defined in:
- lib/queryable/chainable.rb
Overview
Internal: Contains the Chainable class methods.
Instance Method Summary collapse
-
#chain(*names) ⇒ Object
Public: Makes an existing method chainable by storing its return value as the internal query, and returning the query object itself.
Instance Method Details
#chain(*names) ⇒ Object
Public: Makes an existing method chainable by storing its return value as the internal query, and returning the query object itself.
Examples:
chain :order_by_name
chain def search(field_values)
field_values.inject(query) { |query, (field, value)|
query.where(field => /#{value}/i)
}
end
25 26 27 |
# File 'lib/queryable/chainable.rb', line 25 def chain(*names) prepend Module.new.tap { |m| Chainable.add_scope_methods(m, names) } end |