Module: Capybara::Screenshot::Callbacks::ClassMethods

Defined in:
lib/capybara-screenshot/callbacks.rb

Instance Method Summary collapse

Instance Method Details

#callbacksObject



13
14
15
# File 'lib/capybara-screenshot/callbacks.rb', line 13

def callbacks
  @callbacks ||= {}
end

#define_callback(name) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/capybara-screenshot/callbacks.rb', line 17

def define_callback name
  callbacks[name] ||= CallbackSet.new

  define_singleton_method name do |&block|
    callbacks[name] << block
  end
end

#run_callbacks(name, *args) ⇒ Object



25
26
27
28
29
# File 'lib/capybara-screenshot/callbacks.rb', line 25

def run_callbacks name, *args
  if cb_set = callbacks[name]
    cb_set.call *args
  end
end