Class: AutomationObject::BluePrint::PageObjectAdapter::Composite
- Inherits:
-
Composite
- Object
- Composite
- AutomationObject::BluePrint::PageObjectAdapter::Composite
- Defined in:
- lib/automation_object/blue_print/page_object_adapter/composite.rb
Overview
Base composite for PageObject adapter
Direct Known Subclasses
AutomaticModalChange, CustomMethod, ElementArray, ElementHash, HockAction, HookElementRequirements
Instance Attribute Summary collapse
Attributes inherited from Composite
#children, #location, #name, #parent
Instance Method Summary collapse
- #create_composite(constant, interface, name) ⇒ Object
-
#get_child(name, options) ⇒ Object
Get child of composite.
-
#get_children(name, options) ⇒ Hash
Get children of composite.
- #get_page_object(adapter_interface) ⇒ Object
- #get_property(name) ⇒ Object
-
#initialize(user_defined_module, constant = nil, name = :top, parent = nil, location = 'top') ⇒ Composite
constructor
A new instance of Composite.
Methods inherited from Composite
#add_has_many_relationships, #add_has_one_relationships, has_many, has_many_relationships, has_one, has_one_relationships, #top
Methods included from Reflection
Methods included from CompositeHook
#after_create_run, #before_create_run, included
Constructor Details
#initialize(user_defined_module, constant = nil, name = :top, parent = nil, location = 'top') ⇒ Composite
Returns a new instance of Composite
24 25 26 27 28 29 |
# File 'lib/automation_object/blue_print/page_object_adapter/composite.rb', line 24 def initialize(user_defined_module, constant = nil, name = :top, parent = nil, location = 'top') self.user_defined_module = user_defined_module self.constant = constant.is_a?(Class) ? constant : nil super(name, parent, location) end |
Instance Attribute Details
#constant ⇒ AutomationObject::PageObject::Base
17 18 19 |
# File 'lib/automation_object/blue_print/page_object_adapter/composite.rb', line 17 def constant @constant end |
#user_defined_module ⇒ Module
14 15 16 |
# File 'lib/automation_object/blue_print/page_object_adapter/composite.rb', line 14 def user_defined_module @user_defined_module end |
Instance Method Details
#create_composite(constant, interface, name) ⇒ Object
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/automation_object/blue_print/page_object_adapter/composite.rb', line 69 def create_composite(constant, interface, name) # Get the Composite Class that corresponds with the PageObjectAdapter Class class_name = interface.name.split('::').last child_location = location + "[#{name}]" require_relative "../composite/#{class_name.to_underscore}" composite_class = AutomationObject::BluePrint::Composite.const_get(class_name) composite_class.new(interface.new(user_defined_module, constant, name, self, child_location)) end |
#get_child(name, options) ⇒ Object
Get child of composite
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/automation_object/blue_print/page_object_adapter/composite.rb', line 35 def get_child(name, ) self.constant.constants.each { |constant_symbol| constant = self.constant.const_get(constant_symbol) # Check to see if constant is a child class of the public PageObject interface next unless constant < get_page_object([:interface]) name = constant.name.split('::').last.to_underscore.to_sym return create_composite(constant, [:interface], name) } nil end |
#get_children(name, options) ⇒ Hash
Get children of composite
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/automation_object/blue_print/page_object_adapter/composite.rb', line 53 def get_children(name, ) new_children = {} self.constant.constants.each { |constant_symbol| constant = self.constant.const_get(constant_symbol) # Check to see if constant is a child class of the public PageObject interface next unless constant < get_page_object([:interface]) name = constant.name.split('::').last.to_underscore.to_sym new_children[name] = create_composite(constant, [:interface], name) } new_children end |
#get_page_object(adapter_interface) ⇒ Object
80 81 82 83 |
# File 'lib/automation_object/blue_print/page_object_adapter/composite.rb', line 80 def get_page_object(adapter_interface) name = adapter_interface.name.split('::').last.to_sym AutomationObject::PageObject.const_get(name) end |
#get_property(name) ⇒ Object
87 88 89 |
# File 'lib/automation_object/blue_print/page_object_adapter/composite.rb', line 87 def get_property(name) self.constant.get_property(name) end |