Class: VzaarApi::Signature::Abstract

Inherits:
Object
  • Object
show all
Includes:
Lib::HasResourceUrl
Defined in:
lib/vzaar_api/signature/abstract.rb

Direct Known Subclasses

Multipart

Constant Summary collapse

X_AMZ_HEADERS =
[
  "x-amz-credential",
  "x-amz-algorithm",
  "x-amz-date",
  "x-amz-signature"
]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Lib::HasResourceUrl

included

Constructor Details

#initialize(attrs = {}) ⇒ Abstract

Returns a new instance of Abstract.



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/vzaar_api/signature/abstract.rb', line 19

def initialize(attrs = {})
  @access_key_id = attrs[:access_key_id]
  @acl = attrs[:acl]
  @bucket = attrs[:bucket]
  @guid = attrs[:guid]
  @key = attrs[:key]
  @policy = attrs[:policy]
  @success_action_status = attrs[:success_action_status]
  @upload_hostname = attrs[:upload_hostname]
  @x_amz_headers = build_x_amz_headers(attrs)
  after_initialize(attrs)
end

Instance Attribute Details

#access_key_idObject (readonly)

Returns the value of attribute access_key_id.



7
8
9
# File 'lib/vzaar_api/signature/abstract.rb', line 7

def access_key_id
  @access_key_id
end

#aclObject (readonly)

Returns the value of attribute acl.



7
8
9
# File 'lib/vzaar_api/signature/abstract.rb', line 7

def acl
  @acl
end

#bucketObject (readonly)

Returns the value of attribute bucket.



7
8
9
# File 'lib/vzaar_api/signature/abstract.rb', line 7

def bucket
  @bucket
end

#content_typeObject (readonly)

Returns the value of attribute content_type.



7
8
9
# File 'lib/vzaar_api/signature/abstract.rb', line 7

def content_type
  @content_type
end

#guidObject (readonly)

Returns the value of attribute guid.



7
8
9
# File 'lib/vzaar_api/signature/abstract.rb', line 7

def guid
  @guid
end

#keyObject (readonly)

Returns the value of attribute key.



7
8
9
# File 'lib/vzaar_api/signature/abstract.rb', line 7

def key
  @key
end

#policyObject (readonly)

Returns the value of attribute policy.



7
8
9
# File 'lib/vzaar_api/signature/abstract.rb', line 7

def policy
  @policy
end

#success_action_statusObject (readonly)

Returns the value of attribute success_action_status.



7
8
9
# File 'lib/vzaar_api/signature/abstract.rb', line 7

def success_action_status
  @success_action_status
end

#upload_hostnameObject (readonly)

Returns the value of attribute upload_hostname.



7
8
9
# File 'lib/vzaar_api/signature/abstract.rb', line 7

def upload_hostname
  @upload_hostname
end

#x_amz_headersObject (readonly)

Returns the value of attribute x_amz_headers.



7
8
9
# File 'lib/vzaar_api/signature/abstract.rb', line 7

def x_amz_headers
  @x_amz_headers
end

Class Method Details

.create(attrs = {}) ⇒ Object



40
41
42
43
# File 'lib/vzaar_api/signature/abstract.rb', line 40

def self.create(attrs = {})
  attrs[:uploader] = UPLOADER
  new Lib::Api.new.post(resource_url, attrs).data
end

Instance Method Details

#after_initialize(attrs = {}) ⇒ Object

Raises:



32
33
34
# File 'lib/vzaar_api/signature/abstract.rb', line 32

def after_initialize(attrs = {})
  raise Error.new('Cannot call #after_initialize on Signature::Abstract')
end

#build_x_amz_headers(attrs) ⇒ Object



45
46
47
48
49
50
# File 'lib/vzaar_api/signature/abstract.rb', line 45

def build_x_amz_headers(attrs)
  X_AMZ_HEADERS.reduce({}) do |col, key|
    col[key] = attrs[key.to_sym]
    col
  end
end

#multipart?Boolean

Returns:

  • (Boolean)

Raises:



36
37
38
# File 'lib/vzaar_api/signature/abstract.rb', line 36

def multipart?
  raise Error.new('Cannot call #multipart? on Signature::Abstract')
end