module Chamomile::Model
Core contract: start/on_start, update(msg), view.
Public Class Methods
Source
# File lib/chamomile/model.rb, line 6 def self.included(base) base.extend(ClassMethods) end
Public Instance Methods
Source
# File lib/chamomile/model.rb, line 34 def update(msg) raise NotImplementedError, "#{self.class} must implement #update(msg) returning a command or nil" end
Source
# File lib/chamomile/model.rb, line 44 def with(**changes) current = instance_variables.to_h { |v| [v.to_s.delete_prefix("@").to_sym, instance_variable_get(v)] } self.class.new(**current, **changes) end
Returns a copy of the model with the given attributes changed.