Module: ActiveFedora::RdfNode::ClassMethods

Defined in:
lib/active_fedora/rdf_node.rb

Instance Method Summary collapse

Instance Method Details

#configObject



184
185
186
# File 'lib/active_fedora/rdf_node.rb', line 184

def config
  @config ||= {}
end

#config_for_predicate(predicate) ⇒ Object



203
204
205
206
207
208
# File 'lib/active_fedora/rdf_node.rb', line 203

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



188
189
190
191
# File 'lib/active_fedora/rdf_node.rb', line 188

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



214
215
216
217
218
219
220
221
# File 'lib/active_fedora/rdf_node.rb', line 214

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



193
194
195
196
197
198
199
200
201
# File 'lib/active_fedora/rdf_node.rb', line 193

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