Class: MarketplaceKit::Services::Config
- Inherits:
-
Object
- Object
- MarketplaceKit::Services::Config
- Defined in:
- lib/marketplace_kit/services/config.rb
Instance Method Summary collapse
- #default_endpoint ⇒ Object
- #endpoint ⇒ Object
- #load(endpoint_name) ⇒ Object
- #set_token(value) ⇒ Object
- #token ⇒ Object
- #url ⇒ Object
Instance Method Details
#default_endpoint ⇒ Object
33 34 35 |
# File 'lib/marketplace_kit/services/config.rb', line 33 def default_endpoint @config.select { |_k, config| config['default']}.keys.first || 'localhost'.freeze end |
#endpoint ⇒ Object
4 5 6 |
# File 'lib/marketplace_kit/services/config.rb', line 4 def endpoint @endpoint end |
#load(endpoint_name) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/marketplace_kit/services/config.rb', line 8 def load(endpoint_name) @config = {} load_config_from '.builder' load_config_from '.builder-autogenerated', required: false @endpoint = endpoint_name || default_endpoint raise Errors::MarketplaceError.new 'Error: Invalid env passed!' if @config[@endpoint].nil? rescue Errno::ENOENT raise Errors::MarketplaceError.new 'Please create .builder file in order to continue.' end |
#set_token(value) ⇒ Object
24 25 26 27 |
# File 'lib/marketplace_kit/services/config.rb', line 24 def set_token(value) @config[@endpoint]['token'] = value save_token(value) end |
#token ⇒ Object
20 21 22 |
# File 'lib/marketplace_kit/services/config.rb', line 20 def token @config[@endpoint]['token'].to_s end |
#url ⇒ Object
29 30 31 |
# File 'lib/marketplace_kit/services/config.rb', line 29 def url @config[@endpoint]['url'].to_s end |