class Desertcart::Operation::Find

Private Instance Methods

fail(status) click to toggle source
# File lib/desertcart/operation/find.rb, line 41
def fail(status)
  failure(
    LedgerSync::Error::OperationError.new(
      operation: self,
      response: response,
      message: "Status code: #{status}"
    ),
    resource: @resource
  )
end
find_in_ledger() click to toggle source
# File lib/desertcart/operation/find.rb, line 12
def find_in_ledger
  case response.status
  when 200
    LedgerSync::Result.Success(response)
  when 404
    not_found
  else
    fail(response.status)
  end
end
not_found() click to toggle source
# File lib/desertcart/operation/find.rb, line 52
def not_found
  failure(
    LedgerSync::Error::OperationError::NotFoundError.new(
      operation: self,
      response: response
    ),
    resource: @resource
  )
end
operate() click to toggle source
# File lib/desertcart/operation/find.rb, line 23
def operate
  find_in_ledger
    .and_then { success }
end
response() click to toggle source
# File lib/desertcart/operation/find.rb, line 28
def response
  @response ||= client.read(
    path: ledger_resource_path
  )
end
success() click to toggle source
Calls superclass method
# File lib/desertcart/operation/find.rb, line 34
def success
  super(
    resource: deserialized_resource,
    response: response
  )
end