module Queryable::Chainable
Public Class Methods
included(base)
click to toggle source
Internal: Adds class methods, and default initialization.
# File lib/queryable/chainable.rb, line 6 def self.included(base) base.extend ClassMethods end
Private Class Methods
add_scope_methods(mod, names)
click to toggle source
Internal: Defines a scope method in the module per each name in the Array.
mod - The Module where the scope methods will be added. names - Names of the methods to chain.
Returns nothing.
# File lib/queryable/chainable.rb, line 38 def self.add_scope_methods(mod, names) names.each do |name| mod.module_eval Chainable.scope_method(name) end end
scope_method(name)
click to toggle source
Internal: Generates the scope interceptor method.
name - Name of the method to convert to a scope.
Returns a String with the code of the scope method.
# File lib/queryable/chainable.rb, line 49 def self.scope_method(name) <<-SCOPE def #{name}(*args) @queryable = super self end SCOPE end