Class: Bartender::Brewery

Inherits:
Object
  • Object
show all
Defined in:
lib/bartender/brewery.rb

Overview

Retrieve information on breweries.

Class Method Summary collapse

Class Method Details

.all(options = {}) ⇒ Object

Retrieve all breweries.

Parameters:

  • options (Hash) (defaults to: {})

    The options for the API request.

Options Hash (options):

  • :order (String)

    The order to sort by (defaults to id ASC).

  • :page (String)

    The page number to request (defautls to 1).

  • :per_page (String)

    The number of breweries to return per page (defaults to 50).

  • :query (String)

    A string to search brewery names with. (optional)

  • :token (String)

    A public token to override the current configuration with (optional).


12
13
14
# File 'lib/bartender/brewery.rb', line 12

def self.all(options = {})
  Bartender::Request.get("/breweries", options)
end

.create(attributes = {}, options = {}) ⇒ String, ...

Create a brewery.

Parameters:

  • attributes (Hash) (defaults to: {})

    The attributes for the brewery.

  • options (Hash) (defaults to: {})

    The options for the API request.

Options Hash (options):

  • :token (String)

    A private token to override the current configuration with.

Returns:

  • (String, Hash, false)

    The location of the new brewery if created, errors hash for validation errors, false otherwise.


22
23
24
# File 'lib/bartender/brewery.rb', line 22

def self.create(attributes = {}, options = {})
  Bartender::Request.post("/breweries", { :brewery => attributes }, options)
end

.delete(id, options = {}) ⇒ Boolean

Deletes a brewery.

Parameters:

  • id (Integer)

    The ID of the brewery to delete.

  • options (Hash) (defaults to: {})

    The options for the API request.

Options Hash (options):

  • :token (String)

    A private token to override the current configuration with (optional).

Returns:

  • (Boolean)

    true if successful, false otherwise.


32
33
34
# File 'lib/bartender/brewery.rb', line 32

def self.delete(id, options = {})
  Bartender::Request.delete("/breweries/#{id}", options)
end

.find(id, options = {}) ⇒ Object

Retrieve a specific brewery.

Parameters:

  • id (Fixnum)

    The ID of the brewery to retrieve.

  • options (Hash) (defaults to: {})

    The options for the API request.

Options Hash (options):

  • :token (String)

    A public token to override the current configuration with (optional).


41
42
43
# File 'lib/bartender/brewery.rb', line 41

def self.find(id, options = {})
  Bartender::Request.get("/breweries/#{id}", options)
end