Class: Kuzya::UrlBuilder

Inherits:
Service show all
Defined in:
lib/kuzya/url_builder.rb

Instance Method Summary collapse

Methods inherited from Service

call

Constructor Details

#initialize(args, config) ⇒ UrlBuilder

Returns a new instance of UrlBuilder.



4
5
6
7
# File 'lib/kuzya/url_builder.rb', line 4

def initialize(args, config)
  @args = args
  @config = config
end

Instance Method Details

#callObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/kuzya/url_builder.rb', line 9

def call
  url = ''

  config.shortcuts.dup.tap do |conf|
    args.each do |key|
      conf = conf.fetch(key, { '_url' => key })
      url += "#{conf.fetch('_url')}/"
    end
  end

  url.chop
end