Class: TrailerVote::Api::Links
- Inherits:
-
Object
- Object
- TrailerVote::Api::Links
show all
- Defined in:
- lib/trailer_vote/api/links.rb
Instance Method Summary
collapse
Constructor Details
#initialize(links) ⇒ Links
Returns a new instance of Links.
6
7
8
|
# File 'lib/trailer_vote/api/links.rb', line 6
def initialize(links)
self.links = links
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *arguments) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/trailer_vote/api/links.rb', line 14
def method_missing(method_name, *arguments)
link_name = method_name
if links.key?(link_name)
return call(link_name, *arguments)
end
if /[a-z_]+/.match? method_name
raise ArgumentError, format(
'Unknown link %<link>s. Available: %<links>s',
link: method_name,
links: links.keys
)
end
super
end
|
Instance Method Details
#[](key) ⇒ Object
31
32
33
|
# File 'lib/trailer_vote/api/links.rb', line 31
def [](key)
links.fetch(key)
end
|
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
10
11
12
|
# File 'lib/trailer_vote/api/links.rb', line 10
def respond_to_missing?(method_name, include_private = false)
links.key?(method_name) || super
end
|