Module: AttributeMethods::ClassMethods
- Defined in:
- lib/total_in/attribute_methods.rb
Instance Method Summary collapse
- #attribute(name) ⇒ Object
- #attribute_names ⇒ Object
- #define_attribute_reader(name) ⇒ Object
- #define_attribute_writer(name) ⇒ Object
- #register_attribute(name) ⇒ Object
Instance Method Details
#attribute(name) ⇒ Object
8 9 10 11 12 |
# File 'lib/total_in/attribute_methods.rb', line 8 def attribute name register_attribute name define_attribute_reader name define_attribute_writer name end |
#attribute_names ⇒ Object
18 19 20 |
# File 'lib/total_in/attribute_methods.rb', line 18 def attribute_names @attribute_names ||= [] end |
#define_attribute_reader(name) ⇒ Object
22 23 24 25 26 |
# File 'lib/total_in/attribute_methods.rb', line 22 def define_attribute_reader name define_method name do read_attribute name end end |
#define_attribute_writer(name) ⇒ Object
28 29 30 31 32 |
# File 'lib/total_in/attribute_methods.rb', line 28 def define_attribute_writer name define_method "#{name}=" do |value| write_attribute name, value end end |
#register_attribute(name) ⇒ Object
14 15 16 |
# File 'lib/total_in/attribute_methods.rb', line 14 def register_attribute name self.attribute_names.push name end |