Class: ActiveFedora::Relationship

Inherits:
Object
  • Object
show all
Defined in:
lib/active_fedora/relationship.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attr = {}) ⇒ Relationship

Returns a new instance of Relationship.



6
7
8
9
10
11
12
13
# File 'lib/active_fedora/relationship.rb', line 6

def initialize(attr={})
  attr.merge!({:is_literal => false})
  self.subject = attr[:subject]
  @predicate = attr[:predicate]
  self.object = attr[:object]
  @is_literal = attr[:is_literal]
  @data_type = attr[:data_type]
end

Instance Attribute Details

#data_typeObject

Returns the value of attribute data_type.



5
6
7
# File 'lib/active_fedora/relationship.rb', line 5

def data_type
  @data_type
end

#is_literalObject

Returns the value of attribute is_literal.



5
6
7
# File 'lib/active_fedora/relationship.rb', line 5

def is_literal
  @is_literal
end

#objectObject

Returns the value of attribute object.



5
6
7
# File 'lib/active_fedora/relationship.rb', line 5

def object
  @object
end

#predicateObject

Returns the value of attribute predicate.



5
6
7
# File 'lib/active_fedora/relationship.rb', line 5

def predicate
  @predicate
end

#subjectObject

Returns the value of attribute subject.



5
6
7
# File 'lib/active_fedora/relationship.rb', line 5

def subject
  @subject
end

Instance Method Details

#generate_uri(input) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/active_fedora/relationship.rb', line 31

def generate_uri(input)
  if input.class == Symbol || input == nil
    return input
  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



27
28
29
# File 'lib/active_fedora/relationship.rb', line 27

def object_pid=(pid)
  @object = "info:fedora/#{pid}"
end

#subject_pid=(pid) ⇒ Object



19
20
21
# File 'lib/active_fedora/relationship.rb', line 19

def subject_pid=(pid)
  @subject = "info:fedora/#{pid}"
end