class DaFunk::CallbackFlow
Attributes
before[R]
bind[R]
block[R]
next[RW]
Public Class Methods
new(bind, callback, &block)
click to toggle source
# File lib/da_funk/callback_flow.rb, line 6 def initialize(bind, callback, &block) @bind = bind @block = block @before = callback callback.next = self if callback end
Public Instance Methods
check(value)
click to toggle source
# File lib/da_funk/callback_flow.rb, line 19 def check(value) unless [true, nil, false].include?(value) value = check_keyboard(value) end value end
dispatch(result)
click to toggle source
# File lib/da_funk/callback_flow.rb, line 13 def dispatch(result) return if result.nil? bind.setup route(check(bind.instance_exec(result, &block))) end
route(result)
click to toggle source
# File lib/da_funk/callback_flow.rb, line 26 def route(result) if result if @next @next.dispatch(result) else true end elsif result.nil? else @before.dispatch(true) end end
Private Instance Methods
check_keyboard(value)
click to toggle source
# File lib/da_funk/callback_flow.rb, line 40 def check_keyboard(value) case value when Device::IO::CANCEL; return nil when Device::IO::BACK; return false when Device::IO::ENTER; return true end true end