Module: MassiveRecord::ORM::AttributeMethods
- Extended by:
- ActiveSupport::Concern
- Includes:
- ActiveModel::AttributeMethods, ActiveModel::MassAssignmentSecurity
- Defined in:
- lib/massive_record/orm/attribute_methods/read.rb,
lib/massive_record/orm/attribute_methods/dirty.rb,
lib/massive_record/orm/attribute_methods/write.rb,
lib/massive_record/orm/attribute_methods/time_zone_conversion.rb,
lib/massive_record/orm/attribute_methods.rb
Defined Under Namespace
Modules: ClassMethods, Dirty, Read, TimeZoneConversion, Write
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
51
52
53
54
55
56
57
58
|
# File 'lib/massive_record/orm/attribute_methods.rb', line 51
def method_missing(method, *args, &block)
unless self.class.attribute_methods_generated?
self.class.define_attribute_methods
send(method, *args, &block)
else
super
end
end
|
Instance Method Details
#attributes ⇒ Object
33
34
35
|
# File 'lib/massive_record/orm/attribute_methods.rb', line 33
def attributes
Hash[@attributes.collect { |attr_name, raw_value| [attr_name, read_attribute(attr_name)] }]
end
|
#attributes=(new_attributes) ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/massive_record/orm/attribute_methods.rb', line 37
def attributes=(new_attributes)
return unless new_attributes.is_a?(Hash)
sanitize_for_mass_assignment(new_attributes).each do |attr, value|
writer_method = "#{attr}="
if respond_to? writer_method
send(writer_method, value)
else
raise UnknownAttributeError.new("Unkown attribute: #{attr}")
end
end
end
|
#respond_to?(*args) ⇒ Boolean
60
61
62
63
|
# File 'lib/massive_record/orm/attribute_methods.rb', line 60
def respond_to?(*args)
self.class.define_attribute_methods unless self.class.attribute_methods_generated?
super
end
|