Sha256: f9d4841dc38afabf0a305bb3cdf19a5ab16b6151aa2d0457985d7a2f9f0236eb
Contents?: true
Size: 1.6 KB
Versions: 6
Compression:
Stored size: 1.6 KB
Contents
require 'her/model' # This class in the main element of Her. It defines which API models will be bound to. class Camunda::Model include Her::Model # We use a lambda so that this is evaluated after Camunda::Workflow.configuration is set api = lambda do # Configuration for Her and Faraday requests and responses Her::API.new(url: File.join(Camunda::Workflow.configuration.engine_url)) do |c| c.path_prefix = Camunda::Workflow.configuration.engine_route_prefix # Request c.use Faraday::Request::Multipart c.use FaradayMiddleware::EncodeJson c.use Faraday::Request::BasicAuthentication, Camunda::Workflow.configuration.camunda_user, Camunda::Workflow.configuration.camunda_password # Response c.use Faraday::Response::Logger, ActiveSupport::Logger.new(STDOUT), bodies: true if Rails.env.development? c.use Her::Middleware::FirstLevelParseJSON c.use Her::Middleware::SnakeCase # Adapter c.adapter :net_http end end use_api api # 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) find_by(params).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 class RecordNotFound < StandardError end end
Version data entries
6 entries across 6 versions & 1 rubygems