Module: ActiveRecord::NamedScope::ClassMethods
- Defined in:
- lib/fake_arel/extensions.rb
Instance Method Summary collapse
- #named_scope(name, options = {}, &block) ⇒ Object
-
#scoped(scope = {}, &block) ⇒ Object
make all arguments optional, like Rails 3.
- #scoping(&block) ⇒ Object
Instance Method Details
#named_scope(name, options = {}, &block) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/fake_arel/extensions.rb', line 9 def named_scope(name, = {}, &block) name = name.to_sym scopes[name] = lambda do |parent_scope, *args| Scope.new(parent_scope, case when Hash, Scope when Proc .call(*args) end, &block) end singleton_class.send :define_method, name do |*args| scopes[name].call(self, *args) end end |
#scoped(scope = {}, &block) ⇒ Object
make all arguments optional, like Rails 3
27 28 29 |
# File 'lib/fake_arel/extensions.rb', line 27 def scoped(scope = {}, &block) ActiveRecord::NamedScope::Scope.new(self, scope, &block) end |
#scoping(&block) ⇒ Object
5 6 7 |
# File 'lib/fake_arel/extensions.rb', line 5 def scoping(&block) scoped(&block) end |