class PactBroker::Api::Resources::BranchVersion

Public Instance Methods

allowed_methods() click to toggle source
# File lib/pact_broker/api/resources/branch_version.rb, line 16
def allowed_methods
  ["GET", "PUT", "OPTIONS"]
end
content_types_accepted() click to toggle source
# File lib/pact_broker/api/resources/branch_version.rb, line 12
def content_types_accepted
  [["application/json", :from_json]]
end
content_types_provided() click to toggle source
# File lib/pact_broker/api/resources/branch_version.rb, line 8
def content_types_provided
  [["application/hal+json", :to_json]]
end
from_json() click to toggle source
# File lib/pact_broker/api/resources/branch_version.rb, line 28
def from_json
  already_existed = !!branch_version
  @branch_version = branch_service.find_or_create_branch_version(identifier_from_path)
  # Make it return a 201 by setting the Location header
  response.headers["Location"] = branch_version_url(branch_version, base_url) unless already_existed
  response.body = to_json
end
policy_name() click to toggle source
# File lib/pact_broker/api/resources/branch_version.rb, line 36
def policy_name
  :'versions::branch_version'
end
resource_exists?() click to toggle source
# File lib/pact_broker/api/resources/branch_version.rb, line 20
def resource_exists?
  !!branch_version
end
to_json() click to toggle source
# File lib/pact_broker/api/resources/branch_version.rb, line 24
def to_json
  decorator_class(:branch_version_decorator).new(branch_version).to_json(decorator_options)
end

Private Instance Methods

branch_version() click to toggle source
# File lib/pact_broker/api/resources/branch_version.rb, line 42
def branch_version
  @branch_version ||= branch_service.find_branch_version(identifier_from_path)
end