class Roda::Endpoints::Endpoint

Generic HTTP endpoint abstraction.

Generic HTTP endpoint abstraction.

Generic HTTP endpoint abstraction.

Generic HTTP endpoint abstraction.

Generic HTTP endpoint abstraction.

Generic HTTP endpoint abstraction.

Generic HTTP endpoint abstraction.

Attributes

captures[R]

@return [Array]

on[R]

@return [String, Symbol]

Public Class Methods

new(**attributes) click to toggle source

@param attributes [{Symbol=>Object}]

# File lib/roda/endpoints/endpoint.rb, line 38
def initialize(**attributes)
  self.class.defaults.merge(attributes).each do |key, value|
    singleton_class.define_attribute(key) unless respond_to?(key)
    instance_variable_set(:"@#{key}", value)
  end
end

Public Instance Methods

child(type: Singleton, **params) click to toggle source

@param [Class(Endpoint)] type @param [Hash] params

# File lib/roda/endpoints/endpoint.rb, line 69
def child(type: Singleton, **params)
  with(type: type, **params)
end
inheritable_attributes() click to toggle source

@return [{Symbol=>Object}]

# File lib/roda/endpoints/endpoint.rb, line 74
def inheritable_attributes
  { parent: self, container: container }
end
route() click to toggle source

@return [Proc]

# File lib/roda/endpoints/endpoint.rb, line 79
def route
  prepare_validations!
  prepare_verbs!
  prepare_transactions!
  self.class.route
end
to_hash() click to toggle source

@return [{Symbol=>Object}]

# File lib/roda/endpoints/endpoint.rb, line 87
def to_hash
  self.class.attributes.each_with_object({}) do |name, hash|
    hash[name] = public_send(name)
  end
end
type() click to toggle source

@return [Symbol]

# File lib/roda/endpoints/endpoint.rb, line 57
def type
  self.class.type
end
with(type: self.class, **attributes) click to toggle source

@param type [:collection, :item] @param attributes [{Symbol=>Object}]

# File lib/roda/endpoints/endpoint.rb, line 63
def with(type: self.class, **attributes)
  type.new to_hash.merge(attributes).merge(inheritable_attributes)
end