class Routemaster::Responses::HateoasResponse

Attributes

response[R]

Public Class Methods

new(response, client: nil) click to toggle source
# File lib/routemaster/responses/hateoas_response.rb, line 13
def initialize(response, client: nil)
  @response = response
  @client = client || Routemaster::APIClient.new(response_class: self.class)
end

Public Instance Methods

has?(link) click to toggle source
# File lib/routemaster/responses/hateoas_response.rb, line 37
def has?(link)
  _links.has_key?(link.to_s)
end
method_missing(m, *args, &block) click to toggle source
Calls superclass method
# File lib/routemaster/responses/hateoas_response.rb, line 18
def method_missing(m, *args, &block)
  method_name = m.to_s
  normalized_method_name = method_name == '_self' ? 'self' : method_name

  if _links.keys.include?(normalized_method_name)
    unless respond_to?(method_name)
      resource = Resources::RestResource.new(_links[normalized_method_name]['href'], client: @client)
      define_singleton_method(method_name) { resource }
      public_send method_name
    end
  else
    super
  end
end

Private Instance Methods