Method: Tripod::Links::ClassMethods#linked_to

Defined in:
lib/tripod/links.rb

#linked_to(name, predicate, options = {}) ⇒ LinkedTo

Define a link to another resource. Creates relevant fields and getter/setter methods. Note that the getter only retrives saved resources from the db.

Examples:

Define a link away from resources of this class to resources of class Organisation

linked_to :organisation, 'http://example.com/name'

Define a multivalued link away from resources of this class (can be combined with other options)

linked_to :organisations, 'http://example.com/modified_at',  multivalued: true

Define a link away from resources of this class, specifying the class and the field name that will be generated

linked_to :org, 'http://example.com/modified_at', class_name: 'Organisation', field: my_field

Parameters:

  • name (Symbol)

    The name of the link.

  • predicate (String, RDF::URI)

    The predicate for the field.

  • options (Hash) (defaults to: {})

    The options to pass to the field.

Options Hash (options):

  • multivalued (Boolean)

    Is this a multi-valued field? Default is false.

  • class_name (String)

    The name of the class of resource which we’re linking to (normally will derive this from the link name)

  • field_name (Symbol)

    the symbol of the field that will be generated (normally will just add _uri or _uris to the link name)

Returns:



38
39
40
# File 'lib/tripod/links.rb', line 38

def linked_to(name, predicate, options = {})
  add_linked_to(name, predicate, options)
end