Class: ActiveFedora::RdfNode::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/active_fedora/rdf_node.rb

Defined Under Namespace

Classes: IndexObject

Instance Method Summary collapse

Constructor Details

#initialize(parent) ⇒ Builder

Returns a new instance of Builder.



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

def initialize(parent)
  @parent = parent
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
# File 'lib/active_fedora/rdf_node.rb', line 248

def method_missing(name, *args, &block)
  args = args.first if args.respond_to? :first
  raise "mapping must specify RDF vocabulary as :in argument" unless args.has_key? :in
  vocab = args[:in]
  field = args.fetch(:to, name).to_sym
  class_name = args[:class_name]
  raise "Vocabulary '#{vocab.inspect}' does not define property '#{field.inspect}'" unless vocab.respond_to? field
  indexing = false
  if block_given?
    # needed for solrizer integration
    indexing = true
    iobj = IndexObject.new
    yield iobj
    data_type = iobj.data_type
    behaviors = iobj.behaviors
  end
  @parent.config[name] = {:predicate => vocab.send(field) } 
  # stuff data_type and behaviors in there for to_solr support
  if indexing
    @parent.config[name][:type] = data_type
    @parent.config[name][:behaviors] = behaviors
  end
  @parent.config[name][:class_name] = class_name if class_name
end

Instance Method Details

#build {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



244
245
246
# File 'lib/active_fedora/rdf_node.rb', line 244

def build(&block)
  yield self
end