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.
168 169 170 |
# File 'lib/active_fedora/rdf_node.rb', line 168 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
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/active_fedora/rdf_node.rb', line 176 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
172 173 174 |
# File 'lib/active_fedora/rdf_node.rb', line 172 def build(&block) yield self end |