class GH::NestedResources

Public: …

Public Instance Methods

add(hash, link, name, path = name) click to toggle source
# File lib/gh/nested_resources.rb, line 16
def add(hash, link, name, path = name)
  hash["_links"][name] ||= { "href" => nested(link, path) }
end
modify_hash(hash, loaded = false) click to toggle source
Calls superclass method
# File lib/gh/nested_resources.rb, line 9
def modify_hash(hash, loaded = false)
  hash = super(hash)
  link = hash['_links']['self'] unless loaded or hash['_links'].nil?
  set_links hash, Addressable::URI.parse(link['href']) if link
  hash
end
nested(link, path) click to toggle source
# File lib/gh/nested_resources.rb, line 20
def nested(link, path)
  new_link = link.dup
  if path.start_with? '/'
    new_link.path = path
  else
    new_link.path += path
  end
  new_link
end