Method: ActiveRecord::AttributeMethods::ClassMethods#define_attribute_methods
- Defined in:
- lib/active_record/attribute_methods.rb
#define_attribute_methods ⇒ Object Also known as: define_read_methods
Generates all the attribute related methods for columns in the database accessors, mutators and query methods.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/active_record/attribute_methods.rb', line 69 def define_attribute_methods return if generated_methods? columns_hash.each do |name, column| unless instance_method_already_implemented?(name) if self.serialized_attributes[name] define_read_method_for_serialized_attribute(name) elsif create_time_zone_conversion_attribute?(name, column) define_read_method_for_time_zone_conversion(name) else define_read_method(name.to_sym, name, column) end end unless instance_method_already_implemented?("#{name}=") if create_time_zone_conversion_attribute?(name, column) define_write_method_for_time_zone_conversion(name) else define_write_method(name.to_sym) end end unless instance_method_already_implemented?("#{name}?") define_question_method(name) end end end |