Class: OpenAssets::Protocol::HttpAssetDefinitionLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/openassets/protocol/http_asset_definition_loader.rb

Overview

Asset Definition loader for http or https uri scheme

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ HttpAssetDefinitionLoader

Returns a new instance of HttpAssetDefinitionLoader.



9
10
11
# File 'lib/openassets/protocol/http_asset_definition_loader.rb', line 9

def initialize(url)
  @url = url
end

Instance Attribute Details

#urlObject (readonly)

Returns the value of attribute url.



7
8
9
# File 'lib/openassets/protocol/http_asset_definition_loader.rb', line 7

def url
  @url
end

Instance Method Details

#loadObject

load asset definition



14
15
16
17
18
19
20
21
22
23
# File 'lib/openassets/protocol/http_asset_definition_loader.rb', line 14

def load
  begin
    definition = AssetDefinition.parse_json(RestClient::Request.execute(:method => :get, :url => url, :timeout => 10, :open_timeout => 10))
    definition.asset_definition_url = url
    definition
  rescue => e
    puts e
    nil
  end
end