Class: CommunityZero::CookbookVersionsVersionEndpoint

Inherits:
Endpoint
  • Object
show all
Defined in:
lib/community_zero/endpoints/cookbook_versions_version_endpoint.rb

Overview

The endpoint for interacting with a single cookbook version.

Author:

Constant Summary

Constants inherited from Endpoint

Endpoint::METHODS

Instance Attribute Summary

Attributes inherited from Endpoint

#server

Instance Method Summary collapse

Methods inherited from Endpoint

#call, #initialize, #store, #url_for, #version_url_for

Constructor Details

This class inherits a constructor from CommunityZero::Endpoint

Instance Method Details

#get(request) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/community_zero/endpoints/cookbook_versions_version_endpoint.rb', line 23

def get(request)
  name, version = request.path[1], request.path[-1].gsub('_', '.')

  unless cookbook = store.find(name)
    return respond(404,
      {
        'error_code' => 'NOT_FOUND',
        'error_messages' => ['Resource not found'],
      }
    )
  end

  version = store.latest_version(cookbook) if version == 'latest'
  cookbook = store.find(name, version)
  respond(response_hash_for(cookbook))
end