Sha256: 824d8e9259dd7f33a080e2e1e988142e853412193239bf7ac9f8d014306e3e83

Contents?: true

Size: 930 Bytes

Versions: 8

Compression:

Stored size: 930 Bytes

Contents

# frozen_string_literal: true

class Roda
  module Endpoints
    # Generic HTTP endpoint abstraction.
    class Endpoint
      # Namespacing operations, validations, etc.
      module Namespace
        def self.included(child)
          child.attributes += %i(name ns parent)
        end

        # @param name [Symbol]
        # @param ns [String]
        # @param attributes [{Symbol=>Object}]
        # @param parent [Endpoint?]
        def initialize(name:, ns: name.to_s, parent: Undefined, **attributes)
          @name = name
          @ns = ns
          unless parent == Undefined
            @parent = parent
            @ns = [parent.ns, ns].compact.join('.')
          end
          super(name: name, **attributes)
        end

        # @return [Symbol]
        attr_reader :name

        # @return [String]
        attr_reader :ns

        # @return [Endpoint]
        attr_reader :parent
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

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