class AutomationObject::State::Hook

Hook composite for managing state

Public Instance Methods

after() click to toggle source

Runs the after hook @return [Boolean, nil] return nil unless there is a hook, otherwise boolean depending on success of hook

# File lib/automation_object/state/hook.rb, line 42
def after
  return nil if blue_prints.after.empty?

  hook_action = HookAction.new(driver,
                               blue_prints.after,
                               :hook_action, self, location + '[hook_action]')
  hook_action.run
end
before() click to toggle source

Runs the before hook @return [Boolean, nil] return nil unless there is a hook, otherwise boolean depending on success of hook

# File lib/automation_object/state/hook.rb, line 30
def before
  return nil if blue_prints.before.empty?

  hook_action = HookAction.new(driver,
                               blue_prints.before,
                               :hook_action, self, location + '[hook_action]')

  hook_action.run
end
live?() click to toggle source

@return [Boolean, nil] return nil if no live? check, otherwise boolean

# File lib/automation_object/state/hook.rb, line 13
def live?
  before

  return nil if blue_prints.live?.empty?

  blue_prints.live?.each do |element_requirement_blueprints|
    hook_element_requirement = ElementRequirement.new(self, driver, element_requirement_blueprints, 1)
    return false unless hook_element_requirement.run
  end

  after

  true
end