Class: ActiveFedora::RdfNode::TermProxy
- Inherits:
-
Object
- Object
- ActiveFedora::RdfNode::TermProxy
- Defined in:
- lib/active_fedora/rdf_node/term_proxy.rb
Instance Attribute Summary collapse
-
#graph ⇒ Object
readonly
Returns the value of attribute graph.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#predicate ⇒ Object
readonly
Returns the value of attribute predicate.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
Instance Method Summary collapse
- #<<(*values) ⇒ Object
- #build ⇒ Object
- #delete(*values) ⇒ Object
-
#initialize(graph, subject, predicate, options) ⇒ TermProxy
constructor
A new instance of TermProxy.
- #values ⇒ Object
Constructor Details
#initialize(graph, subject, predicate, options) ⇒ TermProxy
Returns a new instance of TermProxy.
14 15 16 17 18 19 |
# File 'lib/active_fedora/rdf_node/term_proxy.rb', line 14 def initialize(graph, subject, predicate, ) @graph = graph @subject = subject @predicate = predicate @options = end |
Instance Attribute Details
#graph ⇒ Object (readonly)
Returns the value of attribute graph.
5 6 7 |
# File 'lib/active_fedora/rdf_node/term_proxy.rb', line 5 def graph @graph end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/active_fedora/rdf_node/term_proxy.rb', line 5 def @options end |
#predicate ⇒ Object (readonly)
Returns the value of attribute predicate.
5 6 7 |
# File 'lib/active_fedora/rdf_node/term_proxy.rb', line 5 def predicate @predicate end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
5 6 7 |
# File 'lib/active_fedora/rdf_node/term_proxy.rb', line 5 def subject @subject end |
Instance Method Details
#<<(*values) ⇒ Object
27 28 29 30 |
# File 'lib/active_fedora/rdf_node/term_proxy.rb', line 27 def <<(*values) values.each { |value| graph.append(subject, predicate, value) } values end |
#build ⇒ Object
21 22 23 24 25 |
# File 'lib/active_fedora/rdf_node/term_proxy.rb', line 21 def build new_subject = RDF::Node.new graph.graph.insert([subject, predicate, new_subject]) graph.target_class(predicate).new(graph.graph, new_subject) end |
#delete(*values) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/active_fedora/rdf_node/term_proxy.rb', line 32 def delete(*values) values.each do |value| graph.delete_predicate(subject, predicate, value) end values end |
#values ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/active_fedora/rdf_node/term_proxy.rb', line 40 def values values = [] graph.query(subject, predicate).each do |solution| v = solution.value v = v.to_s if v.is_a? RDF::Literal if [:type] == :date v = Date.parse(v) end values << v end if [:class_name] values = values.map{ |found_subject| graph.target_class(predicate).new(graph.graph, found_subject)} end values end |