method
define_non_cyclic_method
v4.2.7 -
Show latest stable
- Class:
ActiveRecord::AutosaveAssociation::ClassMethods
define_non_cyclic_method(name, &block)private
No documentation available.
# File activerecord/lib/active_record/autosave_association.rb, line 149
def define_non_cyclic_method(name, &block)
return if method_defined?(name)
define_method(name) do |*args|
result = true; @_already_called ||= {}
# Loop prevention for validation of associations
unless @_already_called[name]
begin
@_already_called[name]=true
result = instance_eval(&block)
ensure
@_already_called[name]=false
end
end
result
end
end