Module: ActiveGraph::Shared::Callbacks

Extended by:
ActiveSupport::Concern
Included in:
Node::Callbacks, Relationship::Callbacks
Defined in:
lib/active_graph/shared/callbacks.rb

Overview

:nodoc:

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#conditional_callback(kind, guard) ⇒ Object

Allows you to perform a callback if a condition is not satisfied.

Parameters:

  • kind (Symbol)

    The callback type to execute unless the guard is true

  • guard (TrueClass, FalseClass)

    When this value is true, the block is yielded without executing callbacks.



40
41
42
43
# File 'lib/active_graph/shared/callbacks.rb', line 40

def conditional_callback(kind, guard)
  return yield if guard
  run_callbacks(kind) { yield }
end

#destroyObject

:nodoc:



22
23
24
25
26
27
28
29
30
31
# File 'lib/active_graph/shared/callbacks.rb', line 22

def destroy #:nodoc:
  ActiveGraph::Base.validating_transaction do |tx|
    tx.after_commit { run_callbacks(:destroy_commit) {} }
    run_callbacks(:destroy) { super }
  end
rescue
  @_deleted = false
  @attributes = @attributes.dup
  raise
end

#initialize(args = nil) ⇒ Object



18
19
20
# File 'lib/active_graph/shared/callbacks.rb', line 18

def initialize(args = nil)
  run_callbacks(:initialize) { super }
end

#touchObject

:nodoc:



33
34
35
# File 'lib/active_graph/shared/callbacks.rb', line 33

def touch #:nodoc:
  run_callbacks(:touch) { super }
end