class Beryl::BackendRuntime
Attributes
state[R]
Public Class Methods
new(state, view)
click to toggle source
# File lib/beryl/backend_runtime.rb, line 5 def initialize(state, view) @messages = [] @state = state @view = view @commands = [] end
Public Instance Methods
process_all_messages()
click to toggle source
# File lib/beryl/backend_runtime.rb, line 16 def process_all_messages while @messages.any? message = @messages.shift result = transition(message.first, message.last) @state = result.is_a?(Array) ? result.first : result command = result.is_a?(Array) ? result[1] : nil run_command(result[1], result[2]) if command if @commands.any? while @commands.any? do end # TODO: refactor process_all_messages end end end
push(message)
click to toggle source
# File lib/beryl/backend_runtime.rb, line 12 def push(message) @messages << message end
run()
click to toggle source
# File lib/beryl/backend_runtime.rb, line 30 def run process render end
run_command(type, payload)
click to toggle source
# File lib/beryl/backend_runtime.rb, line 35 def run_command(type, payload) puts 'running command' end
transition(type, payload)
click to toggle source
# File lib/beryl/backend_runtime.rb, line 39 def transition(type, payload) case type when :IncrementClicked @state.merge(counter: @state[:counter] + 1) when :LoadClicked [@state, :FetchData, key_1: 1, key_2: 2] when :LoadSuccess @state.merge(content: payload[:data]) end end