Method: AutomationObject::BluePrint::PageObjectAdapter.build

Defined in:
lib/automation_object/blue_print/page_object_adapter.rb

.build(path = '') ⇒ AutomationObject::BluePrint::Composite::Top

Returns Composite BluePrint Object.

Parameters:

  • path (String) (defaults to: '')

    path to PageObject classes

Returns:



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/automation_object/blue_print/page_object_adapter.rb', line 19

def build(path = '')
  # Require ruby files in that path into a module namespace
  path = File.expand_path(path)

  defined_module = define_random_module()

  # Remove any defined classes in UserDefined namespace
  defined_module.constants.select do |constant|
    defined_module.const_get(constant).is_a? Class
    defined_module.remove_const(constant)
  end

  # Add classes defined into UserDefined module
  Dir[File.join(path, '**/*.rb')].each do |file|
    defined_module.module_eval(File.read(file))
  end

  # Will look for classes defined
  adapter_top = self::Top.new(defined_module)
  AutomationObject::BluePrint::Composite::Top.new(adapter_top)
end