method
generate_method
v8.1.1 -
Show latest stable
- Class:
ActiveRecord::Delegation::GeneratedRelationMethods
generate_method(method)public
No documentation available.
# File activerecord/lib/active_record/relation/delegation.rb, line 73
def generate_method(method)
MUTEX.synchronize do
return if method_defined?(method)
if /\A[a-zA-Z_]\w*[!?]?\z/.match?(method) && !::ActiveSupport::Delegation::RESERVED_METHOD_NAMES.include?(method.to_s)
module_eval def #{method}(...) scoping { model.#{method}(...) } end, __FILE__, __LINE__ + 1
else
define_method(method) do |*args, **kwargs, &block|
scoping { model.public_send(method, *args, **kwargs, &block) }
end
end
end
end