Sha256: 790e0ceedc094758d7655e51f894ad57094cc3e9ad88f309bf95c7ba007809d2

Contents?: true

Size: 884 Bytes

Versions: 6

Compression:

Stored size: 884 Bytes

Contents

# frozen_string_literal: true

require 'roda/endpoints'
require 'inflecto'

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.#{Inflecto.pluralize(name)}",
                       **attributes)
          @repository_key = repository
          super(name: name, **attributes)
        end

        # @return [String]
        attr_reader :repository_key

        # @return [ROM::Repository]
        def repository
          if @repository_key.is_a?(String)
            container[@repository_key]
          else
            @repository_key
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
roda-endpoints-0.3.6 lib/roda/endpoints/endpoint/data.rb
roda-endpoints-0.3.5 lib/roda/endpoints/endpoint/data.rb
roda-endpoints-0.3.4 lib/roda/endpoints/endpoint/data.rb
roda-endpoints-0.3.3 lib/roda/endpoints/endpoint/data.rb
roda-endpoints-0.3.2 lib/roda/endpoints/endpoint/data.rb
roda-endpoints-0.3.1 lib/roda/endpoints/endpoint/data.rb