class React::StateWrapper
Public Class Methods
new(native, from)
click to toggle source
# File lib/react/state.rb, line 3 def initialize(native, from) @state_hash = Hash.new(`#{native}.state`) @from = from end
Public Instance Methods
[](state)
click to toggle source
# File lib/react/state.rb, line 8 def [](state) @state_hash[state] end
[]=(state, new_value)
click to toggle source
# File lib/react/state.rb, line 12 def []=(state, new_value) @state_hash[state] = new_value end
method_missing(method, *args)
click to toggle source
# File lib/react/state.rb, line 16 def method_missing(method, *args) if match = method.match(/^(.+)\!$/) if args.count > 0 current_value = State.get_state(@from, match[1]) State.set_state(@from, $1, args[0]) current_value else current_state = State.get_state(@from, match[1]) State.set_state(@from, $1, current_state) Observable.new(current_state) do |update| State.set_state(@from, $1, update) end end else State.get_state(@from, method) end end