Method: Tripod::Links::ClassMethods#linked_from

Defined in:
lib/tripod/links.rb

#linked_from(name, incoming_field_name, options = {}) ⇒ LinkedTo

Define that another resource links to this one. Creates a getter with the name you specify. For this to work, the incoming class needs to define a linked_to relationship. Just creates the relevant getter which always return an array of objects.

  linked_from :dogs, :owner

  linked_from :doggies, :person, class_name: ‘Dog’

 @option options [ String ] class_name The name of the class that links to this resource, if we can’t guess it from the link name

Examples:

make a method called people which returns Dog objects, via the linked_to :owner field on Dog. We guess the class name based on the linked_from name.

make a method called doggies which returns Dog objects, via the linked_to :person field on Dog.



60
61
62
# File 'lib/tripod/links.rb', line 60

def linked_from(name, incoming_field_name, options = {})
  add_linked_from(name, incoming_field_name, options)
end