Sha256: d296403509a123cfb9d88ba989e2e7f1e0ac976ad86b56fd048199968ccd585e

Contents?: true

Size: 605 Bytes

Versions: 5

Compression:

Stored size: 605 Bytes

Contents

module Blacklight
  # These are data types that blacklight can use to coerce values from the index
  module Types
    class Array
      def self.coerce(input)
        ::Array.wrap(input)
      end
    end

    class String
      def self.coerce(input)
        ::Array.wrap(input).first
      end
    end

    class Date
      def self.coerce(input)
        field = String.coerce(input)
        return if field.blank?
        begin
          ::Date.parse(field)
        rescue ArgumentError
          Rails.logger.info "Unable to parse date: #{field.first.inspect}"
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
blacklight-6.25.0 app/values/blacklight/types.rb
blacklight-6.24.0 app/values/blacklight/types.rb
blacklight-6.23.0 app/values/blacklight/types.rb
blacklight-6.22.0 app/values/blacklight/types.rb
blacklight-7.0.0.rc1 app/values/blacklight/types.rb