Class: GrowViral::Keystore::ApplicationFetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/keystore/application_fetcher.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(provider, name, deps) ⇒ ApplicationFetcher

Returns a new instance of ApplicationFetcher.



9
10
11
12
13
# File 'lib/keystore/application_fetcher.rb', line 9

def initialize(provider, name, deps)
  @provider = provider
  @name = name
  @config = deps[:config]
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



8
9
10
# File 'lib/keystore/application_fetcher.rb', line 8

def config
  @config
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/keystore/application_fetcher.rb', line 8

def name
  @name
end

#providerObject (readonly)

Returns the value of attribute provider.



8
9
10
# File 'lib/keystore/application_fetcher.rb', line 8

def provider
  @provider
end

Class Method Details

.fetch(*args) ⇒ Object



4
5
6
# File 'lib/keystore/application_fetcher.rb', line 4

def self.fetch(*args)
  new(*args).fetch
end

Instance Method Details

#fetchObject



15
16
17
18
# File 'lib/keystore/application_fetcher.rb', line 15

def fetch
  response = Net::HTTP.get_response(uri)
  Application.new JSON.parse(response.body)
end

#uriObject



20
21
22
# File 'lib/keystore/application_fetcher.rb', line 20

def uri
  @uri ||= URI.parse("#{config.host}/applications/#{name}?provider=#{provider}")
end