Class: PageObjectify::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/page-objectify/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**keywords) ⇒ Config

Returns a new instance of Config.



5
6
7
8
9
10
11
12
13
# File 'lib/page-objectify/config.rb', line 5

def initialize(**keywords)
  @generator_class = keywords[:generator_class] # => "GooglePageGenerator"
  truncated = @generator_class.chomp("Generator")
  @page = keywords[:page] || truncated # => "GooglePage"
  @base = keywords[:base] || "BasePage"
  @file = keywords[:file] || "#{underscorize(truncated)}.rb" # => google_page.rb
  @method_name_mapping = keywords[:method_name_mapping] || []
  validate_configs
end

Instance Attribute Details

#baseObject (readonly)

Returns the value of attribute base.



3
4
5
# File 'lib/page-objectify/config.rb', line 3

def base
  @base
end

#fileObject (readonly)

Returns the value of attribute file.



3
4
5
# File 'lib/page-objectify/config.rb', line 3

def file
  @file
end

#generator_classObject (readonly)

Returns the value of attribute generator_class.



3
4
5
# File 'lib/page-objectify/config.rb', line 3

def generator_class
  @generator_class
end

#method_name_mappingObject (readonly)

Returns the value of attribute method_name_mapping.



3
4
5
# File 'lib/page-objectify/config.rb', line 3

def method_name_mapping
  @method_name_mapping
end

#pageObject (readonly)

Returns the value of attribute page.



3
4
5
# File 'lib/page-objectify/config.rb', line 3

def page
  @page
end

Instance Method Details

#validate_configsObject



15
16
17
18
19
# File 'lib/page-objectify/config.rb', line 15

def validate_configs
  fail "@page must be a String! @page=#{@page.inspect}" unless @page.is_a?(String)
  fail "@base must be a String! @base=#{@base.inspect}" unless @base.is_a?(String)
  fail "@file must end with '.rb'! @file=#{@file.inspect}" unless @file.end_with?(".rb")
end