Skip to content

Commit

Permalink
Merged in GGP-139-add-slug-to-graphgist-json (pull request neo4j-exam…
Browse files Browse the repository at this point in the history
…ples#60)

GGP-139: add slug to graphgist json

Approved-by: Alisson Patricio <[email protected]>
Approved-by: Cristina E <[email protected]>
  • Loading branch information
nossila authored and whatSocks committed Jan 26, 2018
2 parents 61e6808 + 7ee3602 commit dc8ec0e
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions app/views/graph_starter/assets/show.json.jbuilder
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
@asset.class.authorized_properties(current_user).each do |property|
next if @asset.class.hidden_json_properties.include?(property.name.to_sym)

json.set! property.name, @asset.read_attribute(property.name)
end

@asset.class.json_methods.each do |method_name|
json.set! method_name, @asset.send(method_name)
end

json.summary @asset.summary

json.image_urls @asset.reload.image_array.map(&:source_url)

json.categories @asset.categories

@asset.class.authorized_associations.each do |name, association|
value = case association.type
when :has_many
@asset.send(name).to_a
when :has_one
@asset.send(name)
else
fail "Invalid association: #{association.inspect}"
end

json.set! name, value
end

json.slug @asset.slug

json.id @asset.id

0 comments on commit dc8ec0e

Please sign in to comment.