Class: Inform::Command

Inherits:
Object show all
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

Instance Method Summary collapse

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

#argsObject (readonly)

Returns the value of attribute args.



436
437
438
# File 'lib/runtime/command.rb', line 436

def args
  @args
end

#contextObject (readonly)

Returns the value of attribute context.



436
437
438
# File 'lib/runtime/command.rb', line 436

def context
  @context
end

#futureObject

Returns the value of attribute future.



435
436
437
# File 'lib/runtime/command.rb', line 435

def future
  @future
end

#identityObject (readonly)

Returns the value of attribute identity.



436
437
438
# File 'lib/runtime/command.rb', line 436

def identity
  @identity
end

#nameObject (readonly)

Returns the value of attribute name.



436
437
438
# File 'lib/runtime/command.rb', line 436

def name
  @name
end

#semaphoreObject (readonly)

Returns the value of attribute semaphore.



436
437
438
# File 'lib/runtime/command.rb', line 436

def semaphore
  @semaphore
end

#timeObject (readonly)

Returns the value of attribute time.



436
437
438
# File 'lib/runtime/command.rb', line 436

def time
  @time
end

#typeObject (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