Module: Thwart::Actor::InstanceMethods

Defined in:
lib/thwart/actor.rb

Instance Method Summary collapse

Instance Method Details

#thwart_roleObject

The role of this particular actor instance If the class level @role_from is a symbol, it is the name of the instance method to get the role If the class level @role_from is a proc, call it If the above are unsuccessful, use the default if it exists



28
29
30
31
32
33
# File 'lib/thwart/actor.rb', line 28

def thwart_role
  r = self.send(self.class.role_from) if self.class.role_from.is_a?(Symbol) && self.respond_to?(self.class.role_from)
  r ||= self.class.role_from.call(self) if self.class.role_from.respond_to?(:call)
  r ||= self.class.default_role unless self.class.default_role.nil?
  r
end