method
define_attribute_method
v3.1.0 -
Show latest stable
-
0 notes -
Class: ActiveModel::AttributeMethods::ClassMethods
- 1.0.0
- 1.1.0
- 1.1.1
- 1.1.6
- 1.2.0
- 1.2.6
- 2.0.0
- 2.0.1
- 2.0.3
- 2.1.0
- 2.2.1
- 2.3.2
- 2.3.8
- 3.0.0
- 3.0.5
- 3.0.7
- 3.0.9
- 3.1.0 (0)
- 3.2.1 (0)
- 3.2.3 (0)
- 3.2.8 (0)
- 3.2.13 (0)
- What's this?
define_attribute_method(attr_name)
public
Hide source
# File activemodel/lib/active_model/attribute_methods.rb, line 285 def define_attribute_method(attr_name) attribute_method_matchers.each do |matcher| unless instance_method_already_implemented?(matcher.method_name(attr_name)) generate_method = "define_method_#{matcher.prefix}attribute#{matcher.suffix}" if respond_to?(generate_method) send(generate_method, attr_name) else method_name = matcher.method_name(attr_name) generated_attribute_methods.module_eval if method_defined?('#{method_name}') undef :'#{method_name}' end, __FILE__, __LINE__ + 1 if method_name.to_s =~ COMPILABLE_REGEXP generated_attribute_methods.module_eval def #{method_name}(*args) send(:#{matcher.method_missing_target}, '#{attr_name}', *args) end, __FILE__, __LINE__ + 1 else generated_attribute_methods.module_eval define_method('#{method_name}') do |*args| send('#{matcher.method_missing_target}', '#{attr_name}', *args) end, __FILE__, __LINE__ + 1 end end end end end


