Module: Foobara::Entity::Concerns::Callbacks::ClassMethods

Defined in:
foobara-0.5.8/projects/entities/projects/entity/src/concerns/callbacks.rb

Instance Method Summary collapse

Instance Method Details

#class_callback_registryObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'projects/entities/projects/entity/src/concerns/callbacks.rb', line 45

def class_callback_registry
  @class_callback_registry ||= begin
    actions = [
      :initialized,
      :initialized_built,
      :initialized_thunk,
      :initialized_loaded,
      :initialized_created,
      :dirtied,
      :undirtied,
      :attribute_changed,
      :reverted,
      :loaded,
      :persisted,
      :hard_deleted,
      :unhard_deleted,
      :invalidated,
      :uninvalidated
    ]

    if self == Entity
      Callback::Registry::MultipleAction.new(actions).tap do |registry|
        registry.allowed_types = [:after]
      end
    else
      Callback::Registry::ChainedMultipleAction.new(superclass.class_callback_registry)
    end
  end
end

#possible_actionsObject



79
80
81
# File 'projects/entities/projects/entity/src/concerns/callbacks.rb', line 79

def possible_actions
  class_callback_registry.possible_actions
end

#register_callbackObject



75
76
77
# File 'projects/entities/projects/entity/src/concerns/callbacks.rb', line 75

def register_callback(...)
  class_callback_registry.register_callback(...)
end