module ActiveEnumerable::Scopes

Public Class Methods

included(base) click to toggle source
# File lib/active_enumerable/scopes.rb, line 36
def self.included(base)
  base.extend(ClassMethods)
end

Public Instance Methods

method_missing(meth, *args, &block) click to toggle source
Calls superclass method
# File lib/active_enumerable/scopes.rb, line 4
def method_missing(meth, *args, &block)
  if create_scope_method(meth)
    send(meth, *args, &block)
  else
    super
  end
end
respond_to_missing?(meth, _include_private = false) click to toggle source
# File lib/active_enumerable/scopes.rb, line 12
def respond_to_missing?(meth, _include_private = false)
  create_scope_method(meth)
end

Private Instance Methods

create_scope_method(meth) click to toggle source
# File lib/active_enumerable/scopes.rb, line 16
def create_scope_method(meth)
  if (scope = self.class.__scoped_methods__.find { |a| a.first == meth })
    self.define_singleton_method(scope.first) do
      scope(&scope.last)
    end
  end
end