Sha256: c838499d96ae6e41572dda506ae0a954ee7017e4132f8dda88b9d48e88aebd40

Contents?: true

Size: 780 Bytes

Versions: 4

Compression:

Stored size: 780 Bytes

Contents

# frozen_string_literal: true

module Checkpoint
  module DB
    # Sequel model for grants
    class Grant < Sequel::Model(DB.db)
      # Instantiate a Grant from the constituent domain objects (agent,
      # resource, credential).
      def self.from(agent, credential, resource, zone: default_zone)
        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

4 entries across 4 versions & 1 rubygems

Version Path
checkpoint-1.1.3 lib/checkpoint/db/grant.rb
checkpoint-1.1.2 lib/checkpoint/db/grant.rb
checkpoint-1.1.1 lib/checkpoint/db/grant.rb
checkpoint-1.1.0 lib/checkpoint/db/grant.rb