class Screengem::AutomaticVisit

Knows how to decorate public screen element methods with a visit invocation around any public method.

This behaviour is turned on for any screen element instance that overrides the visit_path method.

Attributes

screen_element[R]

Public Class Methods

new(screen_element) click to toggle source
# File lib/screengem/automatic_visit.rb, line 10
def initialize(screen_element)
  @screen_element = screen_element
end

Public Instance Methods

method_missing(method, *args) click to toggle source
Calls superclass method
# File lib/screengem/automatic_visit.rb, line 14
def method_missing(method, *args)
  if screen_element.respond_to?(method)
    forward_with_auto_visit(method, args)
  else
    super
  end
end
respond_to_missing?(method, *) click to toggle source
# File lib/screengem/automatic_visit.rb, line 22
def respond_to_missing?(method, *)
  screen_element.respond_to?(method)
end

Private Instance Methods

auto_visit?(method) click to toggle source
# File lib/screengem/automatic_visit.rb, line 34
def auto_visit?(method)
  methods_to_decorate.include?(method)
end
forward_with_auto_visit(method, args) click to toggle source
# File lib/screengem/automatic_visit.rb, line 28
def forward_with_auto_visit(method, args)
  screen_element.visit if auto_visit?(method)

  screen_element.send(method, *args)
end
methods_to_decorate() click to toggle source
# File lib/screengem/automatic_visit.rb, line 38
def methods_to_decorate
  @methods_to_decorate ||= screen_element.public_methods(true) - [:visit, :visit_path]
end