Class: ActiveFedora::Relationship
- Inherits:
-
Object
- Object
- ActiveFedora::Relationship
- Defined in:
- lib/active_fedora/relationship.rb
Instance Attribute Summary collapse
-
#data_type ⇒ Object
Returns the value of attribute data_type.
-
#is_literal ⇒ Object
Returns the value of attribute is_literal.
-
#object ⇒ Object
Returns the value of attribute object.
-
#predicate ⇒ Object
Returns the value of attribute predicate.
-
#subject ⇒ Object
Returns the value of attribute subject.
Instance Method Summary collapse
- #generate_uri(input) ⇒ Object
-
#initialize(attr = {}) ⇒ Relationship
constructor
A new instance of Relationship.
- #object_pid=(pid) ⇒ Object
- #subject_pid=(pid) ⇒ Object
Constructor Details
#initialize(attr = {}) ⇒ Relationship
Returns a new instance of Relationship.
7 8 9 10 11 12 13 14 |
# File 'lib/active_fedora/relationship.rb', line 7 def initialize(attr={}) attr = {:is_literal => false}.merge(attr) @is_literal = attr[:is_literal] # must happen first self.subject = attr[:subject] @predicate = attr[:predicate] self.object = attr[:object] @data_type = attr[:data_type] end |
Instance Attribute Details
#data_type ⇒ Object
Returns the value of attribute data_type.
6 7 8 |
# File 'lib/active_fedora/relationship.rb', line 6 def data_type @data_type end |
#is_literal ⇒ Object
Returns the value of attribute is_literal.
6 7 8 |
# File 'lib/active_fedora/relationship.rb', line 6 def is_literal @is_literal end |
#object ⇒ Object
Returns the value of attribute object.
6 7 8 |
# File 'lib/active_fedora/relationship.rb', line 6 def object @object end |
#predicate ⇒ Object
Returns the value of attribute predicate.
6 7 8 |
# File 'lib/active_fedora/relationship.rb', line 6 def predicate @predicate end |
#subject ⇒ Object
Returns the value of attribute subject.
6 7 8 |
# File 'lib/active_fedora/relationship.rb', line 6 def subject @subject end |
Instance Method Details
#generate_uri(input) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/active_fedora/relationship.rb', line 32 def generate_uri(input) if input.class == Symbol || input == nil return input elsif input.is_a? URI::Generic return input.to_s elsif input.respond_to?(:pid) return "info:fedora/#{input.pid}" else input.include?("info:fedora") ? input : "info:fedora/#{input}" end end |
#object_pid=(pid) ⇒ Object
28 29 30 |
# File 'lib/active_fedora/relationship.rb', line 28 def object_pid=(pid) @object = "info:fedora/#{pid}" end |
#subject_pid=(pid) ⇒ Object
20 21 22 |
# File 'lib/active_fedora/relationship.rb', line 20 def subject_pid=(pid) @subject = "info:fedora/#{pid}" end |