class Grape::Router::AttributeTranslator

this could be an OpenStruct, but doesn't work in Ruby 2.3.0, see bugs.ruby-lang.org/issues/12251

Constants

ROUTER_ATTRIBUTES
ROUTE_ATTRIBUTES

Attributes

attributes[R]

Public Class Methods

new(**attributes) click to toggle source
# File lib/grape/router/attribute_translator.rb, line 26
def initialize(**attributes)
  @attributes = attributes
end

Public Instance Methods

method_missing(method_name, *args) click to toggle source
# File lib/grape/router/attribute_translator.rb, line 40
def method_missing(method_name, *args)
  if setter?(method_name[-1])
    attributes[method_name[0..-1]] = *args
  else
    attributes[method_name]
  end
end
respond_to_missing?(method_name, _include_private = false) click to toggle source
# File lib/grape/router/attribute_translator.rb, line 48
def respond_to_missing?(method_name, _include_private = false)
  if setter?(method_name[-1])
    true
  else
    @attributes.key?(method_name)
  end
end
to_h() click to toggle source
# File lib/grape/router/attribute_translator.rb, line 36
def to_h
  attributes
end

Private Instance Methods

setter?(method_name) click to toggle source
# File lib/grape/router/attribute_translator.rb, line 58
def setter?(method_name)
  method_name[-1] == '='
end