Module: Tramp::AttributeMethods
- Extended by:
- ActiveSupport::Concern
- Includes:
- ActiveModel::AttributeMethods
- Included in:
- Base
- Defined in:
- lib/tramp/attribute_methods.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #attributes=(attributes) ⇒ Object
- #read_attribute(name) ⇒ Object
- #write_attribute(name, value) ⇒ Object
Instance Method Details
#attributes=(attributes) ⇒ Object
58 59 60 61 62 |
# File 'lib/tramp/attribute_methods.rb', line 58 def attributes=(attributes) attributes.each do |(name, value)| send("#{name}=", value) end end |
#read_attribute(name) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/tramp/attribute_methods.rb', line 50 def read_attribute(name) if ma = self.class.model_attributes[name] ma.type_cast(@attributes[name]) else @attributes[name] end end |
#write_attribute(name, value) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/tramp/attribute_methods.rb', line 40 def write_attribute(name, value) if ma = self.class.model_attributes[name.to_sym] value = ma.check_value!(value) end if(@attributes[name] != value) send "#{name}_will_change!".to_sym @attributes[name] = value end end |