Module: MarkMapper::Plugins::Scopes::ClassMethods
- Defined in:
- lib/mark_mapper/plugins/scopes.rb
Instance Method Summary collapse
Instance Method Details
#scope(name, scope_options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/mark_mapper/plugins/scopes.rb', line 12 def scope(name, ={}) # Assign to _scopes instead of using []= to avoid mixing subclass scopes self._scopes = scopes.merge(name => lambda do |*args| result = .is_a?(Proc) ? .call(*args) : result = self.query(result) if result.is_a?(Hash) self.query.merge(result) end) singleton_class.send :define_method, name, &scopes[name] end |
#scopes ⇒ Object
22 23 24 |
# File 'lib/mark_mapper/plugins/scopes.rb', line 22 def scopes self._scopes ||= {} end |