Class: NucleusCore::Operation

Inherits:
Object
  • Object
show all
Defined in:
lib/nucleus_core/operation.rb

Defined Under Namespace

Classes: Context

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Operation

Returns a new instance of Operation.



40
41
42
# File 'lib/nucleus_core/operation.rb', line 40

def initialize(args={})
  @context = args.is_a?(Context) ? args : Context.new(args)
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



38
39
40
# File 'lib/nucleus_core/operation.rb', line 38

def context
  @context
end

Class Method Details

.call(args = {}) ⇒ Object



44
45
46
47
48
49
50
51
52
# File 'lib/nucleus_core/operation.rb', line 44

def self.call(args={})
  operation = new(args)

  operation.call

  operation.context
rescue Context::Error
  operation.context
end

.rollback(context) ⇒ Object



54
55
56
57
58
59
60
# File 'lib/nucleus_core/operation.rb', line 54

def self.rollback(context)
  operation = new(context)

  operation.rollback

  operation.context
end

Instance Method Details

#callObject



62
63
# File 'lib/nucleus_core/operation.rb', line 62

def call
end

#rollbackObject



65
66
# File 'lib/nucleus_core/operation.rb', line 65

def rollback
end