Sha256: 89ef41d43cea1167c6f6dcdcbe1b96ddf1ce7b07433efb14d3af5184b50fccaf
Contents?: true
Size: 900 Bytes
Versions: 1
Compression:
Stored size: 900 Bytes
Contents
module ActiveEnumerable module Scopes include ScopeMethod def method_missing(meth, *args, &block) if create_scope_method(meth) send(meth, *args, &block) else super end end def respond_to_missing?(meth, include_private = false) if create_scope_method(meth) true else super end end 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 private :create_scope_method module ClassMethods def scope(name, block) __scoped_methods__ << [name, block] end def __scoped_methods__ @__scoped_methods__ ||= [] end end def self.included(base) base.extend(ClassMethods) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_enumerable-0.2.0 | lib/active_enumerable/scopes.rb |