Class: XpRubyClient::Configurator
- Inherits:
-
Object
- Object
- XpRubyClient::Configurator
- Defined in:
- lib/xp_ruby_client/configurator.rb
Defined Under Namespace
Classes: NotSetError
Constant Summary collapse
- ASSIGN_URL_PATH =
"/assigner/application/"- DEFAULT_TIMEOUT =
100
Instance Attribute Summary collapse
-
#application ⇒ Object
Returns the value of attribute application.
-
#assigned ⇒ Object
Returns the value of attribute assigned.
-
#segments ⇒ Object
Returns the value of attribute segments.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
- #base_url ⇒ Object
-
#initialize(&block) ⇒ Configurator
constructor
A new instance of Configurator.
- #to_h ⇒ Object
Constructor Details
#initialize(&block) ⇒ Configurator
Returns a new instance of Configurator.
10 11 12 13 14 15 16 17 18 |
# File 'lib/xp_ruby_client/configurator.rb', line 10 def initialize(&block) @segments = {} @assigned = [] block.call(self) @timeout = DEFAULT_TIMEOUT unless timeout raise(NotSetError, "'application' must be set") unless @application end |
Instance Attribute Details
#application ⇒ Object
Returns the value of attribute application.
8 9 10 |
# File 'lib/xp_ruby_client/configurator.rb', line 8 def application @application end |
#assigned ⇒ Object
Returns the value of attribute assigned.
8 9 10 |
# File 'lib/xp_ruby_client/configurator.rb', line 8 def assigned @assigned end |
#segments ⇒ Object
Returns the value of attribute segments.
8 9 10 |
# File 'lib/xp_ruby_client/configurator.rb', line 8 def segments @segments end |
#timeout ⇒ Object
Returns the value of attribute timeout.
8 9 10 |
# File 'lib/xp_ruby_client/configurator.rb', line 8 def timeout @timeout end |
Instance Method Details
#base_url ⇒ Object
20 21 22 |
# File 'lib/xp_ruby_client/configurator.rb', line 20 def base_url @base_url ||= URI.join(host, ASSIGN_URL_PATH, @application).to_s end |
#to_h ⇒ Object
24 25 26 27 |
# File 'lib/xp_ruby_client/configurator.rb', line 24 def to_h {segments: @segments, assigned: @assigned} end |