Class: FireAndForget::Command::CommandBase
- Inherits:
-
Object
- Object
- FireAndForget::Command::CommandBase
- Defined in:
- lib/fire_and_forget/command.rb
Instance Attribute Summary collapse
-
#cmd ⇒ Object
readonly
Returns the value of attribute cmd.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#tag ⇒ Object
readonly
Returns the value of attribute tag.
-
#task ⇒ Object
readonly
Returns the value of attribute task.
Instance Method Summary collapse
- #debug ⇒ Object
- #dump ⇒ Object
-
#initialize(task, params = {}) ⇒ CommandBase
constructor
A new instance of CommandBase.
- #merge_params(task_params, call_params) ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(task, params = {}) ⇒ CommandBase
Returns a new instance of CommandBase.
23 24 25 |
# File 'lib/fire_and_forget/command.rb', line 23 def initialize(task, params={}) @task, @params = task, merge_params(task.params, params) end |
Instance Attribute Details
#cmd ⇒ Object (readonly)
Returns the value of attribute cmd.
21 22 23 |
# File 'lib/fire_and_forget/command.rb', line 21 def cmd @cmd end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
21 22 23 |
# File 'lib/fire_and_forget/command.rb', line 21 def params @params end |
#tag ⇒ Object (readonly)
Returns the value of attribute tag.
21 22 23 |
# File 'lib/fire_and_forget/command.rb', line 21 def tag @tag end |
#task ⇒ Object (readonly)
Returns the value of attribute task.
21 22 23 |
# File 'lib/fire_and_forget/command.rb', line 21 def task @task end |
Instance Method Details
#debug ⇒ Object
46 47 48 |
# File 'lib/fire_and_forget/command.rb', line 46 def debug() "#{self.class.name.split("::").last} :#{@task_name}\n" end |
#dump ⇒ Object
27 28 29 |
# File 'lib/fire_and_forget/command.rb', line 27 def dump Marshal.dump(self) end |
#merge_params(task_params, call_params) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/fire_and_forget/command.rb', line 36 def merge_params(task_params, call_params) params = task_params.to_a.inject({}) do |hash, (key, value)| hash[key.to_s] = value; hash end call_params.each do |key, value| params[key.to_s] = value end if call_params params end |
#run ⇒ Object
31 32 33 |
# File 'lib/fire_and_forget/command.rb', line 31 def run # overridden in subclasses end |