Class: AutomationObject::BluePrint::PageObjectAdapter::HookElementRequirements

Inherits:
Composite
  • Object
show all
Defined in:
lib/automation_object/blue_print/page_object_adapter/hook_element_requirements.rb

Overview

HookElementRequirements composite

Instance Attribute Summary

Attributes inherited from Composite

#constant, #user_defined_module

Attributes inherited from Composite

#children, #location, #name, #parent

Instance Method Summary collapse

Methods inherited from Composite

#create_composite, #get_child, #get_children, #get_page_object, #get_property, #initialize

Methods inherited from Composite

#add_has_many_relationships, #add_has_one_relationships, #get_child, #get_children, has_many, has_many_relationships, has_one, has_one_relationships, #initialize, #top

Methods included from Reflection

#add_alias, #add_attribute

Methods included from CompositeHook

#after_create_run, #before_create_run, included

Constructor Details

This class inherits a constructor from AutomationObject::BluePrint::PageObjectAdapter::Composite

Instance Method Details

#element_blueprints(composite_object = nil) ⇒ AutomationObject::BluePrint::HashAdapter::Element

Convience for getting element blueprints



43
44
45
46
47
48
49
50
51
52
# File 'lib/automation_object/blue_print/page_object_adapter/hook_element_requirements.rb', line 43

def element_blueprints(composite_object = nil)
  composite_object = self unless composite_object

  # Traverse!
  return composite_object.elements[element_name] if composite_object.hash[:elements].is_a?(Hash)

  return element_blueprints(composite_object.parent) if composite_object.parent

  nil
end

#element_nameSymbol

Get name of the element

Returns:

  • (Symbol)

    name of element



30
31
32
33
34
35
36
37
38
39
# File 'lib/automation_object/blue_print/page_object_adapter/hook_element_requirements.rb', line 30

def element_name
  element_name = hash[:element_name]

  case element_name
    when Symbol, String
      return element_name.to_sym
    else
      return nil
  end
end

#hook_orderArray<Symbol>

Get the order to run the hook in

Returns:

  • (Array<Symbol>)

    list of hook methods to run in given order



12
13
14
15
16
17
18
19
20
# File 'lib/automation_object/blue_print/page_object_adapter/hook_element_requirements.rb', line 12

def hook_order
  hook_order = [:exists?] # Always put exists? first

  hash.each_key do |hook_name|
    hook_order.push(hook_name) unless %i[element_name exists?].include?(hook_name)
  end

  hook_order
end

#requirement(name) ⇒ Object

Get element requirement

Parameters:

  • name (Symbol)

    name of requested requirement



24
25
26
# File 'lib/automation_object/blue_print/page_object_adapter/hook_element_requirements.rb', line 24

def requirement(name)
  hash[name] ||= nil
end