Sha256: 617817da3115710ebc93893f2eb868ec179da693647abac804723837cc0da7aa

Contents?: true

Size: 1017 Bytes

Versions: 54

Compression:

Stored size: 1017 Bytes

Contents

class Ey::Core::Client
  class Real
    def create_addon(params={})
      url = params.delete("url") or raise "URL needed"
      request(
        :method => :post,
        :url    => url,
        :params => params,
      )
    end
  end # Real

  class Mock
    def create_addon(params={})
      url        = params.delete("url") or raise "URL needed"
      account_id = path_params(url)["accounts"] or raise "Need account id, not parsed from #{url}"

      resource_id = self.serial_id

      resource = params["addon"].merge(
        "id"                 => resource_id,
        "addon_attachments"  => url_for("/accounts/#{account_id}/addons/#{resource_id}/attachments"),
        "account"            => url_for("/accounts/#{account_id}"),
        "vars"               => normalize_hash(params["addon"]["vars"] || {}),
      )

      self.data[:addons][resource_id] = resource

      response(
        :body    => {"addon" => resource},
        :status  => 201,
      )
    end
  end # Mock
end # Ey::Core::Client

Version data entries

54 entries across 54 versions & 3 rubygems

Version Path
ey-core-3.6.0.autoscaling1 lib/ey-core/requests/create_addon.rb
ey-core-3.6.4 lib/ey-core/requests/create_addon.rb
ey-core-3.6.3 lib/ey-core/requests/create_addon.rb
ey-core-3.6.1 lib/ey-core/requests/create_addon.rb
groove-ey-core-3.6.3 lib/ey-core/requests/create_addon.rb
groove-ey-core-3.6.2 lib/ey-core/requests/create_addon.rb
groove-ey-core-3.6.1 lib/ey-core/requests/create_addon.rb
ey-core-3.5.0 lib/ey-core/requests/create_addon.rb
ey-core-3.4.4 lib/ey-core/requests/create_addon.rb
ey-core-3.4.2 lib/ey-core/requests/create_addon.rb
ey-core-3.4.1 lib/ey-core/requests/create_addon.rb
ey-core-3.4.0 lib/ey-core/requests/create_addon.rb
ey-core-3.3.1 lib/ey-core/requests/create_addon.rb
ey-core-3.3.0 lib/ey-core/requests/create_addon.rb
ey-core-3.2.6 lib/ey-core/requests/create_addon.rb
ey-core-3.2.5 lib/ey-core/requests/create_addon.rb
ey-core-3.2.4 lib/ey-core/requests/create_addon.rb
ey-core-3.2.3 lib/ey-core/requests/create_addon.rb
ey-core-3.2.2 lib/ey-core/requests/create_addon.rb
ey-core-3.2.1 lib/ey-core/requests/create_addon.rb