Skip to content

Instantly share code, notes, and snippets.

@michael
Created April 5, 2009 21:55
Show Gist options
  • Select an option

  • Save michael/90555 to your computer and use it in GitHub Desktop.

Select an option

Save michael/90555 to your computer and use it in GitHub Desktop.
resource.attributes.each do |attribute|
puts attribute.property.name
puts "--------------------------------"
# there are 4 possible variants
#######################################
# non-unique value type
# non-unique object type
# unique value type
# unique object type
if attribute.unique? #unique
if attribute.object_type? # unique object
puts attribute.name if attribute.name
else # unique value
puts attribute
end
else # non-unique
if attribute.object_type? # non-unique object type
attribute.each do |resource|
puts resource.name if resource.name
end
else # non-unique value type
attribute.each do |resource|
puts resource if resource
end
end
end
puts # empty line
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment