Class: Tripod::Links::LinkedTo

Inherits:
Object
  • Object
show all
Defined in:
lib/tripod/links/linked_to.rb

Overview

Defines the behaviour for defined links in the resource.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Create the new link with a name and optional additional options.



11
12
13
14
15
16
17
18
19
# File 'lib/tripod/links/linked_to.rb', line 11

def initialize(name, predicate, options = {})
  @name = name
  @options = options
  @predicate = RDF::URI.new(predicate.to_s)
  @multivalued = options[:multivalued] || false
  @class_name = options[:class_name] || @name.to_s.classify
  @field_name = options[:field_name] || (@name.to_s + ( @multivalued ? "_uris" : "_uri" )).to_sym

end

Instance Attribute Details

#class_nameObject

Set readers for the instance variables.



7
8
9
# File 'lib/tripod/links/linked_to.rb', line 7

def class_name
  @class_name
end

#field_nameObject

Set readers for the instance variables.



7
8
9
# File 'lib/tripod/links/linked_to.rb', line 7

def field_name
  @field_name
end

#multivaluedObject Also known as: multivalued?

Set readers for the instance variables.



7
8
9
# File 'lib/tripod/links/linked_to.rb', line 7

def multivalued
  @multivalued
end

#nameObject

Set readers for the instance variables.



7
8
9
# File 'lib/tripod/links/linked_to.rb', line 7

def name
  @name
end

#optionsObject

Set readers for the instance variables.



7
8
9
# File 'lib/tripod/links/linked_to.rb', line 7

def options
  @options
end

#predicateObject

Set readers for the instance variables.



7
8
9
# File 'lib/tripod/links/linked_to.rb', line 7

def predicate
  @predicate
end