Class: Gluer::Registration
- Inherits:
-
Object
- Object
- Gluer::Registration
- Defined in:
- lib/gluer/registration.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #commit ⇒ Object
- #committed? ⇒ Boolean
-
#initialize(definition, context, args, block) ⇒ Registration
constructor
A new instance of Registration.
- #rollback ⇒ Object
- #rolled_back? ⇒ Boolean
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
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/gluer/registration.rb', line 5 def name @name end |
Instance Method Details
#commit ⇒ Object
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
29 30 31 |
# File 'lib/gluer/registration.rb', line 29 def committed? @committed end |
#rollback ⇒ Object
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
33 34 35 |
# File 'lib/gluer/registration.rb', line 33 def rolled_back? @rolled_back end |