Class: AngryMob::Act
- Defined in:
- lib/angry_mob/act.rb,
lib/angry_mob/act/scheduler.rb
Overview
A ‘Builder::Act` groups target calls.
Defined Under Namespace
Classes: Scheduler
Instance Attribute Summary collapse
-
#definition_file ⇒ Object
readonly
Returns the value of attribute definition_file.
-
#mob ⇒ Object
readonly
Returns the value of attribute mob.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#__run_target(nickname, *args, &blk) ⇒ Object
Schedules a target, adding call-location context along the way.
- #act_now(act_name, *args) ⇒ Object
-
#bind(mob, file) ⇒ Object
Binds the act to the mob and the file from which it came.
-
#defaults ⇒ Object
Definition helpers.
-
#gem(*args, &blk) ⇒ Object
bundler + rubygems clusterfuck.
- #in_sub_act(*args, &blk) ⇒ Object
-
#initialize(name, multi, &blk) ⇒ Act
constructor
A new instance of Act.
-
#later ⇒ Object
directly schedule a call on the delayed list.
- #log(message) ⇒ Object
-
#method_missing(nickname, *args, &blk) ⇒ Object
TODO - de-mm.
- #multi? ⇒ Boolean
- #node ⇒ Object
- #notifications ⇒ Object
- #notify ⇒ Object
-
#run!(*arguments) ⇒ Object
Executes the block via ‘instance_exec`.
- #schedule_act(act_name) ⇒ Object
- #schedule_acts_matching(regex, &block) ⇒ Object
- #ui ⇒ Object
Constructor Details
#initialize(name, multi, &blk) ⇒ Act
8 9 10 11 12 |
# File 'lib/angry_mob/act.rb', line 8 def initialize(name,multi,&blk) @name = name @multi = multi @blk = blk end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(nickname, *args, &blk) ⇒ Object
TODO - de-mm
52 53 54 55 |
# File 'lib/angry_mob/act.rb', line 52 def method_missing(nickname,*args,&blk) return super unless @running __run_target(nickname,*args,&blk) end |
Instance Attribute Details
#definition_file ⇒ Object (readonly)
Returns the value of attribute definition_file.
6 7 8 |
# File 'lib/angry_mob/act.rb', line 6 def definition_file @definition_file end |
#mob ⇒ Object (readonly)
Returns the value of attribute mob.
6 7 8 |
# File 'lib/angry_mob/act.rb', line 6 def mob @mob end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/angry_mob/act.rb', line 6 def name @name end |
Class Method Details
.synthesise(mob, name, &blk) ⇒ Object
27 28 29 30 31 |
# File 'lib/angry_mob/act.rb', line 27 def self.synthesise(mob,name,&blk) act = new(name,true,&blk) act.bind(mob,"name") act.run! end |
Instance Method Details
#__run_target(nickname, *args, &blk) ⇒ Object
Schedules a target, adding call-location context along the way.
58 59 60 61 62 63 64 65 |
# File 'lib/angry_mob/act.rb', line 58 def __run_target(nickname,*args,&blk) call = mob.target_mother.target_call(nickname,*args,&blk) call.merge_defaults(defaults.defaults_for(nickname)) call.call(self) call.target end |
#act_now(act_name, *args) ⇒ Object
98 99 100 |
# File 'lib/angry_mob/act.rb', line 98 def act_now act_name, *args mob.act_scheduler.act_now(act_name,*args) end |
#bind(mob, file) ⇒ Object
Binds the act to the mob and the file from which it came.
20 21 22 23 24 25 |
# File 'lib/angry_mob/act.rb', line 20 def bind(mob,file) @mob = mob @definition_file = file mob.act_scheduler.add_act @name, self end |
#defaults ⇒ Object
Definition helpers
75 76 77 |
# File 'lib/angry_mob/act.rb', line 75 def defaults @defaults ||= Target::Defaults.new end |
#gem(*args, &blk) ⇒ Object
bundler + rubygems clusterfuck
47 48 49 |
# File 'lib/angry_mob/act.rb', line 47 def gem(*args,&blk) __run_target(:gem,*args,&blk) end |
#in_sub_act(*args, &blk) ⇒ Object
67 68 69 70 71 |
# File 'lib/angry_mob/act.rb', line 67 def in_sub_act(*args,&blk) sub_act = self.class.new("#{name}-sub-act",true,&blk) sub_act.bind(@mob,@definition_file) sub_act.run!(*args) end |
#later ⇒ Object
directly schedule a call on the delayed list
88 89 90 91 92 |
# File 'lib/angry_mob/act.rb', line 88 def later n = Target::Notify.new(self) mob.notifier.schedule_notification n n end |
#log(message) ⇒ Object
15 |
# File 'lib/angry_mob/act.rb', line 15 def log(); mob.ui.log end |
#multi? ⇒ Boolean
17 |
# File 'lib/angry_mob/act.rb', line 17 def multi?; !!@multi end |
#node ⇒ Object
94 95 96 |
# File 'lib/angry_mob/act.rb', line 94 def node mob.node end |
#notifications ⇒ Object
83 84 85 |
# File 'lib/angry_mob/act.rb', line 83 def notifications mob.notifier end |
#notify ⇒ Object
79 80 81 |
# File 'lib/angry_mob/act.rb', line 79 def notify Target::Notify.new(self) end |
#run!(*arguments) ⇒ Object
Executes the block via ‘instance_exec`
36 37 38 39 40 41 42 43 44 |
# File 'lib/angry_mob/act.rb', line 36 def run!(*arguments) ui.push("act '#{name}'", :bubble => true) do @running = true instance_exec *arguments, &@blk @running = false end end |
#schedule_act(act_name) ⇒ Object
102 103 104 |
# File 'lib/angry_mob/act.rb', line 102 def schedule_act act_name mob.act_scheduler.schedule_act(act_name) end |
#schedule_acts_matching(regex, &block) ⇒ Object
106 107 108 |
# File 'lib/angry_mob/act.rb', line 106 def schedule_acts_matching(regex,&block) mob.act_scheduler.schedule_acts_matching(regex,&block) end |
#ui ⇒ Object
14 |
# File 'lib/angry_mob/act.rb', line 14 def ui; mob.ui end |