lib/ddr/utils.rb in ddr-models-2.0.1 vs lib/ddr/utils.rb in ddr-models-2.1.0.rc1

- old
+ new

@@ -91,11 +91,11 @@ # items for an object with the given identifier) def self.pid_for_identifier(identifier, opts={}) model = opts.fetch(:model, nil) collection = opts.fetch(:collection, nil) objs = [] - ActiveFedora::Base.find_each( { Ddr::IndexFields::IDENTIFIER_ALL => identifier }, { :cast => true } ) { |o| objs << o } + ActiveFedora::Base.find_each( { Ddr::Index::Fields::IDENTIFIER_ALL => identifier }, { :cast => true } ) { |o| objs << o } pids = [] objs.each { |obj| pids << obj.pid } if model.present? objs.each { |obj| pids.delete(obj.pid) unless obj.is_a?(model.constantize) } end @@ -153,8 +153,20 @@ rescue NameError # nothing to do here except that we can't return the reflection object class end end return klass + end + + # Returns a string suitable to index as a Solr date + # @param dt [Date, DateTime, Time] the date/time + # @return [String] + def self.solr_date(dt) + return if dt.nil? + dt.to_time.utc.iso8601 + end + + def self.solr_dates(dts) + dts.map { |dt| solr_date(dt) } end end