Class: ActiveFedora::RdfNode::Builder

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

Instance Method Summary collapse

Constructor Details

#initialize(parent) ⇒ Builder

Returns a new instance of Builder.



229
230
231
232
# File 'lib/active_fedora/rdf_node.rb', line 229

def initialize(parent)
  @parent = parent
  @parent.create_node_accessor(:type)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



238
239
240
241
242
243
244
245
246
247
248
249
# File 'lib/active_fedora/rdf_node.rb', line 238

def method_missing(name, *args, &block)
  args = args.first if args.respond_to? :first
  raise "mapping for '#{name}' must specify RDF vocabulary as :in argument" unless args.kind_of?(Hash) && args.has_key?(:in)
  vocab = args.delete(:in)
  field = args.delete(:to) {name}.to_sym
  raise "Vocabulary '#{vocab.inspect}' does not define property '#{field.inspect}'" unless vocab.respond_to? field
  @parent.config[name] = Rdf::NodeConfig.new(name, vocab.send(field), args).tap do |config|
    config.with_index(&block) if block_given?
  end

  @parent.create_node_accessor(name)
end

Instance Method Details

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

Yields:

  • (_self)

Yield Parameters:



234
235
236
# File 'lib/active_fedora/rdf_node.rb', line 234

def build(&block)
  yield self
end