Module: ActiveFedora::RdfNode::ClassMethods
- Defined in:
- lib/active_fedora/rdf_node.rb
Instance Method Summary collapse
- #config ⇒ Object
- #config_for_predicate(predicate) ⇒ Object
-
#fields ⇒ Object
List of symbols representing the fields for this terminology.
- #map_predicates(&block) ⇒ Object
-
#rdf_subject {|ds| ... } ⇒ Object
Register a ruby block that evaluates to the subject of the graph By default, the block returns the current object’s pid.
-
#rdf_type(uri_or_string = nil) ⇒ Object
Provide the value for the RDF.type of this node.
Instance Method Details
#config ⇒ Object
293 294 295 |
# File 'lib/active_fedora/rdf_node.rb', line 293 def config @config ||= {}.with_indifferent_access end |
#config_for_predicate(predicate) ⇒ Object
325 326 327 328 329 330 |
# File 'lib/active_fedora/rdf_node.rb', line 325 def config_for_predicate(predicate) config.each do |term, value| return term, value if value[:predicate] == predicate end return nil end |
#fields ⇒ Object
List of symbols representing the fields for this terminology. ‘:type’ is excluded because it represents RDF.type and is a fixed value
300 301 302 |
# File 'lib/active_fedora/rdf_node.rb', line 300 def fields config.keys.map(&:to_sym) - [:type] end |
#map_predicates(&block) ⇒ Object
304 305 306 307 |
# File 'lib/active_fedora/rdf_node.rb', line 304 def map_predicates(&block) builder = Builder.new(self) builder.build &block end |
#rdf_subject {|ds| ... } ⇒ Object
Register a ruby block that evaluates to the subject of the graph By default, the block returns the current object’s pid
336 337 338 339 340 341 342 343 |
# File 'lib/active_fedora/rdf_node.rb', line 336 def rdf_subject &block if block_given? return @subject_block = block end # Create a B-node if they don't supply the rdf_subject @subject_block ||= lambda { |ds| RDF::Node.new } end |
#rdf_type(uri_or_string = nil) ⇒ Object
Provide the value for the RDF.type of this node
315 316 317 318 319 320 321 322 323 |
# File 'lib/active_fedora/rdf_node.rb', line 315 def rdf_type(uri_or_string=nil) if uri_or_string uri = uri_or_string.kind_of?(RDF::URI) ? uri_or_string : RDF::URI.new(uri_or_string) self.config[:type] = {predicate: RDF.type} @rdf_type = uri ActiveFedora::RdfNode.rdf_registry[uri] = self end @rdf_type end |