module Chamomile::Application
Primary mixin for Chamomile applications. Combines Model + Commands and provides a declarative callback DSL for handling events.
class Counter include Chamomile::Application def initialize @count = 0 end on_key(:up, "k") { @count += 1 } on_key(:down, "j") { @count -= 1 } on_key("q") { quit } def view "Count: #{@count}" end end
Public Class Methods
Source
# File lib/chamomile/application.rb, line 30 def self.included(base) base.extend(ClassMethods) end
Public Instance Methods
Source
# File lib/chamomile/application.rb, line 37 def update(msg) self.class._dispatch_event(self, msg) end
Default update that dispatches to DSL-registered handlers. If a class defines its own βupdate(msg)`, that takes precedence over this (standard Ruby MRO).