Class: Clapton::State

Inherits:
Object
  • Object
show all
Defined in:
lib/clapton/state.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#attributesObject (readonly)

Returns the value of attribute attributes.



3
4
5
# File 'lib/clapton/state.rb', line 3

def attributes
  @attributes
end

#errorsObject

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_hObject



11
12
13
# File 'lib/clapton/state.rb', line 11

def to_h
  @attributes
end