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
267 268 269 |
# File 'lib/active_fedora/rdf_node.rb', line 267 def config @config ||= {}.with_indifferent_access end |
#config_for_predicate(predicate) ⇒ Object
300 301 302 303 304 305 |
# File 'lib/active_fedora/rdf_node.rb', line 300 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
274 275 276 |
# File 'lib/active_fedora/rdf_node.rb', line 274 def fields config.keys.map(&:to_sym) - [:type] end |
#map_predicates(&block) ⇒ Object
278 279 280 281 |
# File 'lib/active_fedora/rdf_node.rb', line 278 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
311 312 313 314 315 316 317 318 |
# File 'lib/active_fedora/rdf_node.rb', line 311 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
289 290 291 292 293 294 295 296 297 298 |
# File 'lib/active_fedora/rdf_node.rb', line 289 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] = Rdf::NodeConfig.new(RDF.type) @rdf_type = uri logger.warn "Duplicate RDF Class. Trying to register #{self} for #{uri} but it is already registered for #{ActiveFedora::RdfNode.rdf_registry[uri]}" if ActiveFedora::RdfNode.rdf_registry.key? uri ActiveFedora::RdfNode.rdf_registry[uri] = self end @rdf_type end |