Module: Magent::Actor::ClassMethods
- Defined in:
- lib/magent/actor.rb
Instance Method Summary collapse
- #actions ⇒ Object
- #at_least_every(seconds, &block) ⇒ Object
- #can_handle?(action) ⇒ Boolean
- #channel ⇒ Object
- #channel_name(name = nil) ⇒ Object
- #expose(*methods) ⇒ Object
- #tasks ⇒ Object
Instance Method Details
#actions ⇒ Object
21 22 23 |
# File 'lib/magent/actor.rb', line 21 def actions @actions ||= Set.new end |
#at_least_every(seconds, &block) ⇒ Object
39 40 41 |
# File 'lib/magent/actor.rb', line 39 def at_least_every(seconds, &block) tasks << {:every => seconds, :last_time => Time.now, :block => block} end |
#can_handle?(action) ⇒ Boolean
25 26 27 |
# File 'lib/magent/actor.rb', line 25 def can_handle?(action) actions.include?(action.to_s) end |
#channel ⇒ Object
29 30 31 32 33 |
# File 'lib/magent/actor.rb', line 29 def channel @channel ||= begin ActorChannel.new(self.channel_name) end end |
#channel_name(name = nil) ⇒ Object
17 18 19 |
# File 'lib/magent/actor.rb', line 17 def channel_name(name = nil) @channel_name ||= (name || Magent::Utils.underscore(self.name)).to_s end |
#expose(*methods) ⇒ Object
11 12 13 14 15 |
# File 'lib/magent/actor.rb', line 11 def expose(*methods) methods.each do |m| actions << m.to_s end end |
#tasks ⇒ Object
35 36 37 |
# File 'lib/magent/actor.rb', line 35 def tasks @tasks ||= [] end |