Sha256: 60813cc03d007e47c6313045bca394ab87268e9b2e87b798e7f4d75622724852

Contents?: true

Size: 779 Bytes

Versions: 3

Compression:

Stored size: 779 Bytes

Contents

# frozen_string_literal: true

module Checkpoint
  module DB
    # Sequel model for permits
    class Permit < Sequel::Model(DB.db)
      # Instantiate a Permit from the constituent domain objects (agent,
      # resource, credential).
      def self.from(agent, credential, resource, zone: 'system')
        new(
          agent_type: agent.type,           agent_id: agent.id,           agent_token: agent.token,
          credential_type: credential.type, credential_id: credential.id, credential_token: credential.token,
          resource_type: resource.type,     resource_id: resource.id,     resource_token: resource.token,
          zone_id: zone
        )
      end

      # The default/system zone
      def self.default_zone
        '(all)'
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
checkpoint-1.0.3 lib/checkpoint/db/permit.rb
checkpoint-1.0.2 lib/checkpoint/db/permit.rb
checkpoint-1.0.1 lib/checkpoint/db/permit.rb