class JsonApiClient::Linking::TopLevelLinks
Attributes
links[R]
record_class[R]
Public Class Methods
new(record_class, links)
click to toggle source
# File lib/json_api_client/linking/top_level_links.rb, line 7 def initialize(record_class, links) @links = links @record_class = record_class end
Public Instance Methods
fetch_link(link_name)
click to toggle source
# File lib/json_api_client/linking/top_level_links.rb, line 33 def fetch_link(link_name) return unless respond_to_missing?(link_name) record_class.requestor.linked(link_url_for(link_name)) end
link_url_for(link_name)
click to toggle source
# File lib/json_api_client/linking/top_level_links.rb, line 24 def link_url_for(link_name) link_definition = links.fetch(link_name.to_s) if link_definition.is_a?(Hash) link_definition["href"] else link_definition end end
method_missing(method, *args)
click to toggle source
Calls superclass method
# File lib/json_api_client/linking/top_level_links.rb, line 16 def method_missing(method, *args) if respond_to_missing?(method) fetch_link(method) else super end end
respond_to_missing?(method, include_private = false)
click to toggle source
Calls superclass method
# File lib/json_api_client/linking/top_level_links.rb, line 12 def respond_to_missing?(method, include_private = false) links.has_key?(method.to_s) || super end