Class: Clapton::State
- Inherits:
-
Object
- Object
- Clapton::State
- Defined in:
- lib/clapton/state.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#errors ⇒ Object
Returns the value of attribute errors.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ State
constructor
A new instance of State.
- #to_h ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ State
Returns a new instance of State.
6 7 8 9 |
# File 'lib/clapton/state.rb', line 6 def initialize(params = {}) @attributes = params @errors = [] end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
3 4 5 |
# File 'lib/clapton/state.rb', line 3 def attributes @attributes end |
#errors ⇒ Object
Returns the value of attribute errors.
4 5 6 |
# File 'lib/clapton/state.rb', line 4 def errors @errors end |
Class Method Details
.attribute(attribute_name) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/clapton/state.rb', line 15 def self.attribute(attribute_name) define_method(attribute_name) do @attributes[attribute_name.to_sym] end define_method("#{attribute_name}=") do |value| @attributes[attribute_name.to_sym] = value end end |
Instance Method Details
#to_h ⇒ Object
11 12 13 |
# File 'lib/clapton/state.rb', line 11 def to_h @attributes end |