Class: ActiveFedora::RdfNode::Builder
- Inherits:
-
Object
- Object
- ActiveFedora::RdfNode::Builder
- Defined in:
- lib/active_fedora/rdf_node.rb
Defined Under Namespace
Classes: IndexObject
Instance Method Summary collapse
- #build {|_self| ... } ⇒ Object
-
#initialize(parent) ⇒ Builder
constructor
A new instance of Builder.
- #method_missing(name, *args, &block) ⇒ Object
Constructor Details
#initialize(parent) ⇒ Builder
Returns a new instance of Builder.
127 128 129 |
# File 'lib/active_fedora/rdf_node.rb', line 127 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
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/active_fedora/rdf_node.rb', line 135 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
131 132 133 |
# File 'lib/active_fedora/rdf_node.rb', line 131 def build(&block) yield self end |