Module: HyperActiveRecord::QueryMethods
- Defined in:
- lib/hyper_active_record/query_methods.rb
Constant Summary collapse
- APPLIED_SCOPE_MARKER =
:':applied_scope:'
Instance Method Summary collapse
Instance Method Details
#scoped_by(opts) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/hyper_active_record/query_methods.rb', line 18 def scoped_by(opts) opts.inject(clone) do |relation, scope| name, value = *scope relation = value.is_a?(Array) ? relation.send(name, *value) : relation.send(name, value) end end |
#where(opts, *rest) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/hyper_active_record/query_methods.rb', line 8 def where(opts, *rest) return super unless opts.is_a?(Hash) return super if opts.delete(APPLIED_SCOPE_MARKER) , = slice_scopes(opts) relation = self.scoped_by() relation.where(.merge(APPLIED_SCOPE_MARKER => true), *rest) end |