Exception: Common::InvalidActionSequence

Inherits:
InvalidRequest show all
Defined in:
lib/common/cloudbox_exceptions.rb

Overview

Get a message if an action is invalid.

Instance Method Summary collapse

Constructor Details

#initialize(action, currentState, possibilities, entityName, entityType) ⇒ InvalidActionSequence

Note:

Overrides default constructor by passing CustomCommandOption to super().

Default constructor of the class.



420
421
422
423
424
425
426
427
# File 'lib/common/cloudbox_exceptions.rb', line 420

def initialize(action, currentState, possibilities, entityName, entityType)
  @action = action
  @currentState = currentState
  @entityName = entityName
  @entityType = entityType
  @possibilities = possibilities
  super(getMsg())
end

Instance Method Details

#getActionObject

Get an action



430
431
432
# File 'lib/common/cloudbox_exceptions.rb', line 430

def getAction
  return @action
end

#getCurrentStateObject

Get the current state



435
436
437
# File 'lib/common/cloudbox_exceptions.rb', line 435

def getCurrentState
  return @currentState
end

#getEntityNameObject

Get the entity name



440
441
442
# File 'lib/common/cloudbox_exceptions.rb', line 440

def getEntityName
  return @entityName
end

#getEntityTypeObject

Get the entity type



445
446
447
# File 'lib/common/cloudbox_exceptions.rb', line 445

def getEntityType
  return @entityType
end

#getMsgObject (private)

Get the message of the error



451
452
453
454
455
456
457
458
459
460
# File 'lib/common/cloudbox_exceptions.rb', line 451

def getMsg()
  sexyStates = ""
  first = true
  @possibilities[@action]['required_state'].each do |a|
    sexyStates += "|" unless first
    first = false
    sexyStates += a
  end
  msg = "To #{@action} the #{@entityType} #{@entityName}, it has to be in state #{sexyStates} (current: '#{@currentState}')."
end