Module: ActiveFedora::RdfNode::ClassMethods

Defined in:
lib/active_fedora/rdf_node.rb

Instance Method Summary collapse

Instance Method Details

#configObject



221
222
223
# File 'lib/active_fedora/rdf_node.rb', line 221

def config
  @config ||= {}
end

#config_for_predicate(predicate) ⇒ Object



240
241
242
243
244
245
# File 'lib/active_fedora/rdf_node.rb', line 240

def config_for_predicate(predicate)
  config.each do |term, value|
    return term, value if value[:predicate] == predicate
  end
  return nil
end

#map_predicates(&block) ⇒ Object



225
226
227
228
# File 'lib/active_fedora/rdf_node.rb', line 225

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

Yields:

  • (ds)

    ‘ds’ is the datastream instance



251
252
253
254
255
256
257
258
# File 'lib/active_fedora/rdf_node.rb', line 251

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



230
231
232
233
234
235
236
237
238
# File 'lib/active_fedora/rdf_node.rb', line 230

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