def url
prefix = '/'
unless self.class.belongs_to_relationships.empty?
prefix = self.class.belongs_to_relationships.inject(prefix) do |prefix_so_far, relationship|
prefix_so_far.to_s + relationship.to_s + "/" + self.send("#{relationship.to_s}_id").to_s + '/'
end
end
if @attrs['self']
the_url = @attrs['self'].sub(@client.options[:site],'')
the_url = "/#{the_url}" if (the_url =~ /^\//).nil?
the_url
elsif key_value
self.class.singular_path(client, key_value.to_s, prefix)
else
self.class.collection_path(client, prefix)
end
end