Class: ActiveCollection::Scope::ScopeBuilder

Inherits:
Array
  • Object
show all
Defined in:
lib/active_collection/scope.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.build(kind, *methods, &block) ⇒ Object



75
76
77
78
79
# File 'lib/active_collection/scope.rb', line 75

def self.build(kind, *methods, &block)
  methods, options = extract_options(*methods, &block)
  methods.map! { |method| ActiveSupport::Callbacks::Callback.new(kind, method, options) }
  new(methods)
end

Instance Method Details

#to_options(object) ⇒ Object



81
82
83
84
85
86
# File 'lib/active_collection/scope.rb', line 81

def to_options(object)
  inject({}) do |h, callback|
    res = callback.call(object)
    res ? h.merge(res) : h
  end
end