Class: MusicBrainz::Request
- Inherits:
-
Object
- Object
- MusicBrainz::Request
- Defined in:
- lib/musicbrainz/request.rb
Constant Summary collapse
- UNIQUE_IDENTIFIERS =
%q{discid puid isrc iswc}
Instance Method Summary collapse
-
#initialize(resource, params) ⇒ Request
constructor
A new instance of Request.
- #options ⇒ Object
- #path ⇒ Object
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
#options ⇒ Object
22 23 24 25 26 |
# File 'lib/musicbrainz/request.rb', line 22 def = {} [:query] = @params unless @params.empty? end |
#path ⇒ Object
18 19 20 |
# File 'lib/musicbrainz/request.rb', line 18 def path path = "/#{@resource}/#{@id}" end |