Class: Grape::Router::AttributeTranslator
- Inherits:
-
Object
- Object
- Grape::Router::AttributeTranslator
show all
- Defined in:
- lib/grape/router/attribute_translator.rb
Overview
Direct Known Subclasses
Any
Instance Method Summary
collapse
Constructor Details
5
6
7
|
# File 'lib/grape/router/attribute_translator.rb', line 5
def initialize(attributes = {})
@attributes = attributes
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args) ⇒ Object
13
14
15
16
17
18
19
|
# File 'lib/grape/router/attribute_translator.rb', line 13
def method_missing(m, *args)
if m[-1] == '='
@attributes[m[0..-1]] = *args
elsif m[-1] != '='
@attributes[m]
end
end
|
Instance Method Details
#respond_to_missing?(method_name, _include_private = false) ⇒ Boolean
21
22
23
24
25
26
27
|
# File 'lib/grape/router/attribute_translator.rb', line 21
def respond_to_missing?(method_name, _include_private = false)
if method_name[-1] == '='
true
else
@attributes.key?(method_name)
end
end
|
#to_h ⇒ Object
9
10
11
|
# File 'lib/grape/router/attribute_translator.rb', line 9
def to_h
@attributes
end
|