Class: AePageObjects::Application

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/ae_page_objects/core/application.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.called_fromObject

Returns the value of attribute called_from.



8
9
10
# File 'lib/ae_page_objects/core/application.rb', line 8

def called_from
  @called_from
end

Class Method Details

.from(from_mod) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/ae_page_objects/core/application.rb', line 29

def from(from_mod)
  until from_mod == Object
    if from_mod < AePageObjects::Universe
      return from_mod.page_objects_application_class.instance
    end

    from_mod = from_mod.parent
  end

  nil
end

.inherited(application_class) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/ae_page_objects/core/application.rb', line 13

def inherited(application_class)
  super

  application_class.called_from = begin
    call_stack = caller.map { |p| p.sub(/:\d+.*/, '') }
    File.dirname(call_stack.detect { |p| p !~ %r[railties[\w.-]*/lib/rails|rack[\w.-]*/lib/rack] })
  end

  application_class.universe.send(:include, Universe)
  application_class.universe.page_objects_application_class = application_class
end

.universeObject



25
26
27
# File 'lib/ae_page_objects/core/application.rb', line 25

def universe
  parent
end

Instance Method Details

#configObject



50
51
52
# File 'lib/ae_page_objects/core/application.rb', line 50

def config
  @config ||= Configuration.new(self)
end

#initialize!Object



54
55
56
57
# File 'lib/ae_page_objects/core/application.rb', line 54

def initialize!
  ActiveSupport::Dependencies.autoload_paths.unshift(*paths)
  eager_load!
end

#resolve_constant(from_mod, const_name) ⇒ Object



59
60
61
62
63
64
65
66
67
# File 'lib/ae_page_objects/core/application.rb', line 59

def resolve_constant(from_mod, const_name)
  resolver = ConstantResolver.new(self, from_mod, const_name)

  resolved = nil
  paths.each do |path|
    break if resolved = resolver.load_constant_from_path(path)
  end
  resolved
end