Module: LeftJoins

Defined in:
lib/left_joins.rb,
lib/left_joins/version.rb

Constant Summary collapse

IS_RAILS3_FLAG =
Gem::Version.new(ActiveRecord::VERSION::STRING) < Gem::Version.new('4.0.0')
HAS_BUILT_IN_LEFT_JOINS_METHOD =
ActiveRecord::QueryMethods.method_defined?(:left_outer_joins)
VERSION =
"1.0.8"

Class Method Summary collapse

Class Method Details

.patch(target, method, as:) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/left_joins.rb', line 11

def patch(target, method, as:)
  return yield if target.singleton_methods.include?(method)

  target.define_singleton_method(method, &as)
  result = yield
  target.singleton_class.send(:remove_method, method)

  return result
end