Sha256: 5b15bea1a42ee75b95fcfcf3209bf0d6618901890ef028bb6578eb3173ff5e9a

Contents?: true

Size: 829 Bytes

Versions: 1

Compression:

Stored size: 829 Bytes

Contents

require 'spyke/base'
# This class in the main element of Spyke. It defines which API models will be bound to.
class Camunda::Model < Spyke::Base
  # Returns result of find_by but raises an exception instead of returning nil
  # @param params [Hash] query parameters
  # @return [Camunda::Model]
  # @raise [Camunda::Model::RecordNotFound] if query returns no results
  def self.find_by!(params)
    with(base_path).where(params).first.tap do |result|
      raise Camunda::Model::RecordNotFound unless result
    end
  end

  # Returns the worker id
  # @note default worker id is set in Camunda::Workflow.configuration
  # @return [String] id of worker
  def self.worker_id
    Camunda::Workflow.configuration.worker_id
  end

  def self.base_path
    uri.sub("(:id)", '')
  end

  class RecordNotFound < StandardError
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
camunda-workflow-1.0.0 lib/camunda/model.rb