Class: Gexp::Command

Inherits:
Object
  • Object
show all
Extended by:
StateMachine::MacroMethods
Defined in:
lib/gexp/command.rb,
lib/gexp/command/stack.rb,
lib/gexp/command/object.rb

Overview

,Базовый класс комманд

Direct Known Subclasses

Object

Defined Under Namespace

Classes: Object, Stack

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Command

Returns a new instance of Command.



39
40
41
42
43
44
# File 'lib/gexp/command.rb', line 39

def initialize(params = {})
  @params  = params.dup
  @errors  = []
  
  super() # Инициализация StateMachine
end

Instance Attribute Details

#contextObject

Returns the value of attribute context.



12
13
14
# File 'lib/gexp/command.rb', line 12

def context
  @context
end

#errorsObject

Returns the value of attribute errors.



11
12
13
# File 'lib/gexp/command.rb', line 11

def errors
  @errors
end

#eventObject

TODO: only getter



15
16
17
# File 'lib/gexp/command.rb', line 15

def event
  @event
end

#objectObject

Returns the value of attribute object.



17
18
19
# File 'lib/gexp/command.rb', line 17

def object
  @object
end

#paramsObject

Returns the value of attribute params.



13
14
15
# File 'lib/gexp/command.rb', line 13

def params
  @params
end

#providerObject

Returns the value of attribute provider.



19
20
21
# File 'lib/gexp/command.rb', line 19

def provider
  @provider
end

#subjectObject

Returns the value of attribute subject.



18
19
20
# File 'lib/gexp/command.rb', line 18

def subject
  @subject
end

Instance Method Details

#hashString

индетификатор комманды

Returns:

  • (String)


49
50
51
52
53
54
55
56
# File 'lib/gexp/command.rb', line 49

def hash
  # TODO: Заменить на BSON:ObjectId
  [
    @params[:timestamp],
    @params[:event],
    @params[:seed],
  ].join('_')
end

#performObject

Заглушка для исполнения команды

Raises:

  • NotImplementedError



61
62
63
64
65
66
67
# File 'lib/gexp/command.rb', line 61

def perform
  self.activate!
  self.failure!

  raise NotImplementedError.new \
    'Not defined perform method'
end