Class: PewPew::Resources::Routes

Inherits:
Object
  • Object
show all
Includes:
PewPew::Resource
Defined in:
lib/pew_pew/resources/routes.rb

Instance Method Summary collapse

Instance Method Details

#allMash

Fetches all defined routes.

Returns:

  • (Mash)

    the response body



9
10
11
# File 'lib/pew_pew/resources/routes.rb', line 9

def all
  get('routes')
end

#create(params) ⇒ Mash

Creates a new route.

Parameters:

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :priority (Fixnum)

    smaller number indicates higher priority; higher priority routes are handled first; Defaults to 0

  • :description (String)

    arbitrary description of the route

  • :expression (String)

    the filter expression

  • :action (String, Array<String>)

    the route action(s) to be executed when the expression evaluates to true

Returns:

  • (Mash)

    the response body



30
31
32
# File 'lib/pew_pew/resources/routes.rb', line 30

def create(params)
  post('routes', params)
end

#find(id) ⇒ Mash

Fetch a route by ID.

Parameters:

  • id (String)

    the ID of the route to be fetched

Returns:

  • (Mash)

    the response body



17
18
19
# File 'lib/pew_pew/resources/routes.rb', line 17

def find(id)
  get("routes/#{id}")
end

#remove(id) ⇒ Mash

Removes an existing route by ID.

Parameters:

  • id (String)

    the ID of the route to be deleted

Returns:

  • (Mash)

    the response body



52
53
54
# File 'lib/pew_pew/resources/routes.rb', line 52

def remove(id)
  delete("routes/#{id}")
end

#update(id, params) ⇒ Mash

Updates an existing route by ID.

Parameters:

  • id (String)

    the ID of the route to be updated

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :priority (Fixnum)

    smaller number indicates higher priority; higher priority routes are handled first; Defaults to 0

  • :description (String)

    arbitrary description of the route

  • :expression (String)

    the filter expression

  • :action (String, Array<String>)

    the route action(s) to be executed when the expression evaluates to true

Returns:

  • (Mash)

    the response body



44
45
46
# File 'lib/pew_pew/resources/routes.rb', line 44

def update(id, params)
  put("routes/#{id}", params)
end