Module: Delicious::Bundles::Methods::Find

Extended by:
ActiveSupport::Concern
Included in:
Api
Defined in:
lib/delicious/bundles/methods/find.rb

Instance Method Summary collapse

Instance Method Details

#find(name) ⇒ Bundle?

Find a bundle with given name

Parameters:

  • name (String)

    Bundle name

Returns:

  • (Bundle, nil)

    Found bundle or ‘nil` if it was not found



14
15
16
17
18
19
20
21
# File 'lib/delicious/bundles/methods/find.rb', line 14

def find(name)
  response = @client.connection.get '/v1/tags/bundles/all', bundle: name
  bundle = response.body['bundles']['bundle']
  Bundle.build_persisted @client, self.class.model_attrs(bundle)
rescue Faraday::ParsingError => e
  # it's ridiculous, but delicious returns invalid XML response when bundle is missing
  nil
end