Sha256: 5b338f8a3e5ec044a1883cddbaf357a26c36aa1c3d0dc3e883a224aadab6dc93
Contents?: true
Size: 1.51 KB
Versions: 5
Compression:
Stored size: 1.51 KB
Contents
module ActiveTriples class NodeConfig attr_accessor :predicate, :term, :class_name, :type, :behaviors, :multivalue def initialize(term, predicate, args={}) self.term = term self.predicate = predicate self.class_name = args.delete(:class_name) self.multivalue = args.delete(:multivalue) { true } raise ArgumentError, "Invalid arguments for Rdf Node configuration: #{args} on #{predicate}" unless args.empty? end def [](value) value = value.to_sym self.respond_to?(value) ? self.send(value) : nil end def class_name return nil if @class_name.nil? raise "class_name for #{term} is a #{@class_name.class}; must be a class" unless @class_name.kind_of? Class or @class_name.kind_of? String if @class_name.kind_of?(String) begin new_class = @class_name.constantize @class_name = new_class rescue NameError end end @class_name end def with_index (&block) # needed for solrizer integration iobj = IndexObject.new yield iobj self.type = iobj.data_type self.behaviors = iobj.behaviors end # this enables a cleaner API for solr integration class IndexObject attr_accessor :data_type, :behaviors def initialize @behaviors = [] @data_type = :string end def as(*args) @behaviors = args end def type(sym) @data_type = sym end def defaults :noop end end end end
Version data entries
5 entries across 5 versions & 1 rubygems