Class: Napster::Models::UploadedImage

Inherits:
Object
  • Object
show all
Defined in:
lib/napster/models/uploaded_image.rb

Overview

UploadedImage model

Constant Summary collapse

ATTRIBUTES =
[:content_id,
:image_type,
:url,
:default_image,
:image_id,
:version].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(arg) ⇒ UploadedImage

Returns a new instance of UploadedImage.



20
21
22
23
24
25
26
27
# File 'lib/napster/models/uploaded_image.rb', line 20

def initialize(arg)
  @client = arg[:client] if arg[:client]
  return unless arg[:data]

  ATTRIBUTES.each do |attribute|
    send("#{attribute}=", arg[:data][attribute.to_s.camel_case_lower])
  end
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



18
19
20
# File 'lib/napster/models/uploaded_image.rb', line 18

def client
  @client
end

Class Method Details

.collection(arg) ⇒ Object



29
30
31
32
33
# File 'lib/napster/models/uploaded_image.rb', line 29

def self.collection(arg)
  arg[:data].map do |uploaded_image|
    UploadedImage.new(data: uploaded_image, client: @client)
  end
end