Module: Card::Set::Event::Callbacks

Included in:
Card::Set::Event
Defined in:
lib/card/set/event/callbacks.rb

Instance Method Summary collapse

Instance Method Details

#set_event_callback(object_method, kind) ⇒ Object



12
13
14
15
16
17
# File 'lib/card/set/event/callbacks.rb', line 12

def set_event_callback object_method, kind
  Card.class_exec(self) do |event|
    set_callback object_method, kind, event.name,
                 prepend: true, if: proc { |c| c.event_applies?(event) }
  end
end

#set_event_callbacksObject



5
6
7
8
9
10
# File 'lib/card/set/event/callbacks.rb', line 5

def set_event_callbacks
  %i[before after around].each do |kind|
    next unless (object_method = @opts.delete kind)
    set_event_callback object_method, kind
  end
end