Sha256: 26519be0c81f608060b37f593915b8a52001a38acc3e83283e6f87d1f0ab3d7e

Contents?: true

Size: 811 Bytes

Versions: 1

Compression:

Stored size: 811 Bytes

Contents

# frozen_string_literal: true

class Roda
  module Endpoints
    # Generic HTTP endpoint abstraction.
    class Endpoint
      # Accessing data inside of endpoint.
      module Data
        # @param name [String]
        # @param repository [String]
        # @param attributes [{Symbol=>Object}]
        def initialize(name:, repository: "repositories.#{name}", **attributes)
          @repository_key = repository
          super(name: name, **attributes)
        end

        # @return [String]
        attr_reader :repository_key

        # @return [ROM::Repository]
        def repository
          container[@repository_key] if @repository_key
        end

        # @return [{Symbol=>Object}]
        def to_hash
          super.merge(repository: @repository_key)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
roda-endpoints-0.2.0 lib/roda/endpoints/endpoint/data.rb