class Hyalite::Component::State
Public Class Methods
new(component, updator, initial_state)
click to toggle source
# File lib/hyalite/component.rb, line 213 def initialize(component, updator, initial_state) @component = component @updator = updator @state = initial_state.clone initial_state.each do |key, value| define_singleton_method(key) do @state[key] end define_singleton_method(key + '=') do |value| @updator.enqueue_set_state(@component, key => value) end end end
Public Instance Methods
[](key)
click to toggle source
# File lib/hyalite/component.rb, line 227 def [](key) @state[key] end
set(state)
click to toggle source
# File lib/hyalite/component.rb, line 231 def set(state) @state = state.clone end
to_h()
click to toggle source
# File lib/hyalite/component.rb, line 235 def to_h @state end