Module: Hobo::Model::Scopes::ApplyScopes

Included in:
ActiveRecord::Associations::CollectionProxy, ClassMethods
Defined in:
lib/hobo/model/scopes/apply_scopes.rb

Instance Method Summary collapse

Instance Method Details

#apply_scopes(scopes) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/hobo/model/scopes/apply_scopes.rb', line 6

def apply_scopes(scopes)
  result = self
  scopes.each_pair do |scope, arg|
    if arg.is_a?(Array)
      result = result.send(scope, *arg) unless arg.first.blank?
    else
      result = result.send(scope, arg) unless arg.blank?
    end
  end
  result
end