Class: ActiveRecord::QueryMethods::OrChain

Inherits:
Object
  • Object
show all
Defined in:
lib/rearmed/monkey_patches/rails_4.rb

Instance Method Summary collapse

Constructor Details

#initialize(scope) ⇒ OrChain

Returns a new instance of OrChain.



91
92
93
# File 'lib/rearmed/monkey_patches/rails_4.rb', line 91

def initialize(scope)
  @scope = scope
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



95
96
97
98
99
100
# File 'lib/rearmed/monkey_patches/rails_4.rb', line 95

def method_missing(method, *args, &block)
  right_relation = @scope.klass.unscoped do
    @scope.klass.send(method, *args, &block)
  end
  @scope.or(right_relation)
end