Class: Gluer::Registration

Inherits:
Object
  • Object
show all
Defined in:
lib/gluer/registration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(definition, context, args, block) ⇒ Registration

Returns a new instance of Registration.



7
8
9
10
11
12
13
14
# File 'lib/gluer/registration.rb', line 7

def initialize(definition, context, args, block)
  @definition = definition
  @context = context
  @args = args
  @block = block
  @committed = false
  @rolled_back = false
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/gluer/registration.rb', line 5

def name
  @name
end

Instance Method Details

#commitObject

Raises:

  • (RuntimeError)


16
17
18
19
20
# File 'lib/gluer/registration.rb', line 16

def commit
  raise RuntimeError, 'already committed' if committed?
  commit_hook.call(registry, context, *args, &block)
  mark_committed
end

#committed?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/gluer/registration.rb', line 29

def committed?
  @committed
end

#rollbackObject

Raises:

  • (RuntimeError)


22
23
24
25
26
27
# File 'lib/gluer/registration.rb', line 22

def rollback
  raise RuntimeError, 'not committed' unless committed?
  raise RuntimeError, 'already rolled back' if rolled_back?
  rollback_hook.call(registry, context, *args, &block)
  mark_rolled_back
end

#rolled_back?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/gluer/registration.rb', line 33

def rolled_back?
  @rolled_back
end