module Roda::Endpoints::Endpoint::Verbs
Accessing data inside of endpoint.
Attributes
verbs[R]
@return [<Symbol>]
Public Class Methods
new(**attributes)
click to toggle source
@param attributes [{Symbol=>Object}]
Calls superclass method
# File lib/roda/endpoints/endpoint/verbs.rb, line 10 def initialize(**attributes) @verbs = verbs_to_implement(**attributes) super(**attributes) end
Public Instance Methods
implemented_verbs()
click to toggle source
@return [<Symbol>]
# File lib/roda/endpoints/endpoint/verbs.rb, line 29 def implemented_verbs self.class.verbs.to_a end
prepare_verbs!()
click to toggle source
# File lib/roda/endpoints/endpoint/verbs.rb, line 45 def prepare_verbs! return if @verbs_prepared verbs.each do |verb| key = "operations.#{ns}.#{verb}" next if container.key?(key) endpoint = self operation = method(verb) container.register key do |*args| endpoint.instance_exec(*args, &operation) end end @verbs_prepared = true end
verb(verb, **kwargs, &block)
click to toggle source
@param [#to_s] verb @param [Hash] kwargs @param [Proc] block
# File lib/roda/endpoints/endpoint/verbs.rb, line 39 def verb(verb, **kwargs, &block) key = "operations.#{ns}.#{verb}" block ||= container[key] singleton_class.verb(verb, **kwargs, &block) end
verbs_to_implement(only: implemented_verbs, except: [], **_kwargs)
click to toggle source
@param only [<Symbol>] @param except [<Symbol>]
# File lib/roda/endpoints/endpoint/verbs.rb, line 17 def verbs_to_implement(only: implemented_verbs, except: [], **_kwargs) only = Array(only).flatten except = Array(except).flatten if ((unknown_only = only - implemented_verbs) + (unknown_except = except - implemented_verbs)).any? params = { only: unknown_only, except: unknown_except } raise ArgumentError, "unknown verbs in params: #{params}" end only - except end