Module: Tripod::Links::ClassMethods
- Defined in:
- lib/tripod/links.rb
Instance Method Summary collapse
-
#linked_from(name, incoming_field_name, options = {}) ⇒ LinkedTo
Define that another resource links to this one.
-
#linked_to(name, predicate, options = {}) ⇒ LinkedTo
Define a link to another resource.
Instance Method Details
#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
60 61 62 |
# File 'lib/tripod/links.rb', line 60 def linked_from(name, incoming_field_name, = {}) add_linked_from(name, incoming_field_name, ) end |
#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.
38 39 40 |
# File 'lib/tripod/links.rb', line 38 def linked_to(name, predicate, = {}) add_linked_to(name, predicate, ) end |