Class: PageObjectify::Config
- Inherits:
-
Object
- Object
- PageObjectify::Config
- Defined in:
- lib/page-objectify/config.rb
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#generator_class ⇒ Object
readonly
Returns the value of attribute generator_class.
-
#method_name_mapping ⇒ Object
readonly
Returns the value of attribute method_name_mapping.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
Instance Method Summary collapse
-
#initialize(**keywords) ⇒ Config
constructor
A new instance of Config.
- #validate_configs ⇒ Object
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
#base ⇒ Object (readonly)
Returns the value of attribute base.
3 4 5 |
# File 'lib/page-objectify/config.rb', line 3 def base @base end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
3 4 5 |
# File 'lib/page-objectify/config.rb', line 3 def file @file end |
#generator_class ⇒ Object (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_mapping ⇒ Object (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 |
#page ⇒ Object (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_configs ⇒ Object
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 |