Module: IronNails::Models::Databinding::ClassMethods
- Defined in:
- lib/ironnails/models/model_mixin.rb
Instance Method Summary collapse
-
#attr_accessor(*names) ⇒ Object
defines a read/write attribute on an object.
-
#attr_writer(*names) ⇒ Object
defines a write-only attribute on an object this would map to a property setter in different languages.
Instance Method Details
#attr_accessor(*names) ⇒ Object
defines a read/write attribute on an object. this would map to a property with a getter and a setter in different langauages
31 32 33 34 |
# File 'lib/ironnails/models/model_mixin.rb', line 31 def attr_accessor(*names) attr_reader *names attr_writer *names end |
#attr_writer(*names) ⇒ Object
defines a write-only attribute on an object this would map to a property setter in different languages
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ironnails/models/model_mixin.rb', line 17 def attr_writer(*names) names.each do |nm| mn = nm self.send :define_method, "#{nm}=".to_sym do |arg| __vr__ = instance_variable_get :"@#{mn}" return __vr__ if __vr__ == arg instance_variable_set :"@#{mn}", arg raise_property_changed mn end end end |