Class: MusicBrainz::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/musicbrainz/request.rb

Constant Summary collapse

UNIQUE_IDENTIFIERS =
%q{discid puid isrc iswc}

Instance Method Summary collapse

Constructor Details

#initialize(resource, params) ⇒ Request

Returns a new instance of Request.



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/musicbrainz/request.rb', line 6

def initialize(resource, params)
  @resource   = resource
  @params     = params
  @id         = nil

  if UNIQUE_IDENTIFIERS.include?(resource)
    @id = params.delete(resource.to_sym)
  elsif params.has_key?(:mbid)
    @id = params.delete(:mbid)
  end
end

Instance Method Details

#optionsObject



22
23
24
25
26
# File 'lib/musicbrainz/request.rb', line 22

def options
  options = {}
  options[:query] = @params unless @params.empty?
  options
end

#pathObject



18
19
20
# File 'lib/musicbrainz/request.rb', line 18

def path
  path = "/#{@resource}/#{@id}"
end