module MarkMapper::Plugins::Scopes::ClassMethods
Public Instance Methods
scope(name, scope_options={})
click to toggle source
# File lib/mark_mapper/plugins/scopes.rb, line 12 def scope(name, scope_options={}) # Assign to _scopes instead of using []= to avoid mixing subclass scopes self._scopes = scopes.merge(name => lambda do |*args| result = scope_options.is_a?(Proc) ? scope_options.call(*args) : scope_options result = self.query(result) if result.is_a?(Hash) self.query.merge(result) end) singleton_class.send :define_method, name, &scopes[name] end
scopes()
click to toggle source
# File lib/mark_mapper/plugins/scopes.rb, line 22 def scopes self._scopes ||= {} end