Skip to content

Instantly share code, notes, and snippets.

@pzuraq
Created May 28, 2013 04:17
Show Gist options
  • Save pzuraq/5660490 to your computer and use it in GitHub Desktop.
Save pzuraq/5660490 to your computer and use it in GitHub Desktop.
def index(options={}, &block)
respond_with(*(with_chain(collection) << options), &block)
end
def with_chain(object)
association_chain + [ object ]
end
def association_chain
return @association_chain if @association_chain
symbol_chain = if resources_configuration[:self][:singleton]
symbols_for_association_chain.reverse
else
symbols_for_association_chain
end
@association_chain =
symbol_chain.inject([begin_of_association_chain]) do |chain, symbol|
chain << evaluate_parent(symbol, resources_configuration[symbol], chain.last)
end.compact.freeze
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment