Class: Pinnacle::DatumModel
- Inherits:
-
Object
- Object
- Pinnacle::DatumModel
- Defined in:
- lib/pinnacle.rb
Instance Attribute Summary collapse
-
#attrs ⇒ Object
(also: #to_hash)
Returns the value of attribute attrs.
Class Method Summary collapse
-
.lazy_attr_reader(*attrs) ⇒ Object
Define methods that retrieve the value from an initialized instance variable Hash, using the attribute as a key.
Instance Method Summary collapse
-
#initialize(attrs = {}) ⇒ DatumModel
constructor
Initializes a new Base object.
Constructor Details
#initialize(attrs = {}) ⇒ DatumModel
Initializes a new Base object
31 32 33 |
# File 'lib/pinnacle.rb', line 31 def initialize(attrs={}) @attrs = attrs.dup end |
Instance Attribute Details
#attrs ⇒ Object Also known as: to_hash
Returns the value of attribute attrs.
8 9 10 |
# File 'lib/pinnacle.rb', line 8 def attrs @attrs end |
Class Method Details
.self.lazy_attr_reader(attr) ⇒ Object .self.lazy_attr_reader(attrs) ⇒ Object
Define methods that retrieve the value from an initialized instance variable Hash, using the attribute as a key
17 18 19 20 21 22 23 24 25 |
# File 'lib/pinnacle.rb', line 17 def self.lazy_attr_reader(*attrs) attrs.each do |attribute| class_eval do define_method attribute do @attrs[attribute.to_s] || @attrs[attribute.to_sym] end end end end |