Class: Inform::Command
- Includes:
- CommandInitializationMethods
- Defined in:
- lib/runtime/command.rb
Overview
The Inform::Command class
Constant Summary
Constants included from CommandInitializationMethods
CommandInitializationMethods::CallerPattern, CommandInitializationMethods::CommandActivityTemplate, CommandInitializationMethods::CommandAntecedantTemplate, CommandInitializationMethods::CommandCauseIdentityTemplate, CommandInitializationMethods::CommandNameTemplate, CommandInitializationMethods::CommandSourceFullTemplate, CommandInitializationMethods::CommandSourceTemplate
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#future ⇒ Object
Returns the value of attribute future.
-
#identity ⇒ Object
readonly
Returns the value of attribute identity.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#semaphore ⇒ Object
readonly
Returns the value of attribute semaphore.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #contextualize(from) ⇒ Object
- #init_context(context) ⇒ Object
-
#initialize(params = {}, &block) ⇒ Command
constructor
Note that block if given is converted to lambda.
Methods included from CommandInitializationMethods
#defer, #generate_identity, #init_fields, #schedule_or_defer
Constructor Details
#initialize(params = {}, &block) ⇒ Command
Note that block if given is converted to lambda. This enables the use of return statements inside the event activity blocks.
440 441 442 443 444 445 446 447 |
# File 'lib/runtime/command.rb', line 440 def initialize(params = {}, &block) @semaphore = Mutex.new init_fields(params, &block) init_context(@context) puts "Invoking #{self}" invoke(self) # @when == :immediately ? invoke(self) : schedule_or_defer(self) end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
436 437 438 |
# File 'lib/runtime/command.rb', line 436 def args @args end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
436 437 438 |
# File 'lib/runtime/command.rb', line 436 def context @context end |
#future ⇒ Object
Returns the value of attribute future.
435 436 437 |
# File 'lib/runtime/command.rb', line 435 def future @future end |
#identity ⇒ Object (readonly)
Returns the value of attribute identity.
436 437 438 |
# File 'lib/runtime/command.rb', line 436 def identity @identity end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
436 437 438 |
# File 'lib/runtime/command.rb', line 436 def name @name end |
#semaphore ⇒ Object (readonly)
Returns the value of attribute semaphore.
436 437 438 |
# File 'lib/runtime/command.rb', line 436 def semaphore @semaphore end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
436 437 438 |
# File 'lib/runtime/command.rb', line 436 def time @time end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
436 437 438 |
# File 'lib/runtime/command.rb', line 436 def type @type end |
Instance Method Details
#contextualize(from) ⇒ Object
454 455 456 457 458 459 460 461 462 |
# File 'lib/runtime/command.rb', line 454 def contextualize(from) # log.info "Initializing context for command #{self} from #{from} (#{from.class})" Inform::Context.get.members.each do |attribute| value = get_value(from, attribute) warn_when_nilling_noun(from, attribute, value) setter_method = format('%<attribute>s=', attribute: attribute).to_sym send(setter_method, value) end end |
#init_context(context) ⇒ Object
449 450 451 452 |
# File 'lib/runtime/command.rb', line 449 def init_context(context) return if context.nil? contextualize(context) end |