Module: Model::DSL
- Included in:
- Engineering::Builder::Model
- Defined in:
- lib/model/dsl.rb
Overview
Extensions to Model::DSL
Instance Method Summary collapse
-
#attr_accessor(name, value = nil, &block) ⇒ Object
(also: #attribute)
Define a new read-write Model attribute.
-
#attr_reader(name, value = nil, &block) ⇒ Object
Define a new read-only Model attribute.
-
#attr_writer(name) ⇒ Object
Define a new write-only Model attribute.
Instance Method Details
#attr_accessor(name, value = nil, &block) ⇒ Object Also known as: attribute
Define a new read-write Model attribute. An optional default value can be supplied as either an argument, or as a block. The block will be evaluated the first time the attribute is accessed.
7 8 9 10 |
# File 'lib/model/dsl.rb', line 7 def attr_accessor(name, value=nil, &block) define_attribute_reader name, value, &block define_attribute_writer name end |
#attr_reader(name, value = nil, &block) ⇒ Object
Define a new read-only Model attribute. An optional default value can be supplied as either an argument, or as a block. The block will be evaluated the first time the attribute is accessed.
16 17 18 |
# File 'lib/model/dsl.rb', line 16 def attr_reader(name, value=nil, &block) define_attribute_reader(name, value, &block) end |
#attr_writer(name) ⇒ Object
Define a new write-only Model attribute
22 23 24 |
# File 'lib/model/dsl.rb', line 22 def attr_writer(name) define_attribute_writer(name) end |