module Roda::Endpoints::Endpoint::Lookup
Lookup
everything in the container.
Public Instance Methods
container()
click to toggle source
@return [Dry::Container::Mixin]
# File lib/roda/endpoints/endpoint/lookup.rb, line 13 def container @container || parent&.container || Roda::Endpoints.roda_class end
lookup(*paths, key: nil, scope: nil, default: nil)
click to toggle source
@param [<String>] paths
# File lib/roda/endpoints/endpoint/lookup.rb, line 18 def lookup(*paths, key: nil, scope: nil, default: nil) if key && scope paths += lookup_keys(key: key, scope: scope, default: default) end paths.flatten.detect { |full_key| container.key?(full_key) } end
lookup_keys(key:, scope: nil, default: nil, lookup: lookup_path) { |full_key| ... }
click to toggle source
@param [#to_s] key @param [#to_s] scope
# File lib/roda/endpoints/endpoint/lookup.rb, line 27 def lookup_keys(key:, scope: nil, default: nil, lookup: lookup_path) scope = "#{scope}." unless scope.to_s.end_with?('.') keys = [] Array(key).flatten.map do |sect| lookup.each do |choice| [sect, default].compact.each do |value| full_key = "#{scope}#{choice}.#{value}" yield full_key if block_given? keys << full_key end end end keys end
lookup_path()
click to toggle source
# File lib/roda/endpoints/endpoint/lookup.rb, line 42 def lookup_path path = [ns] endpoint = self.class while endpoint < Roda::Endpoints::Endpoint path << endpoint.type endpoint = endpoint.superclass end path end
operation_for(verb)
click to toggle source
@param [Symbol] verb @return [String]
# File lib/roda/endpoints/endpoint/lookup.rb, line 54 def operation_for(verb) lookup key: verb, scope: 'operations.' end
transaction_for(verb)
click to toggle source
@param [Symbol] verb @return [String]
# File lib/roda/endpoints/endpoint/lookup.rb, line 67 def transaction_for(verb) lookup key: verb, scope: 'transactions' end
validation_for(verb)
click to toggle source
@param [Symbol] verb @return [String]
# File lib/roda/endpoints/endpoint/lookup.rb, line 60 def validation_for(verb) lookup(key: verb, default: 'any', scope: 'validations.') || provide_default_validation! end