Sha256: 6a810a07c00963e7d533fbee335956d27299166f103f59fd477e5c980e3bfb53

Contents?: true

Size: 638 Bytes

Versions: 41

Compression:

Stored size: 638 Bytes

Contents

# frozen_string_literal: true

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

41 entries across 41 versions & 1 rubygems

Version Path
blacklight-7.33.1 app/values/blacklight/types.rb
blacklight-7.33.0 app/values/blacklight/types.rb
blacklight-7.32.0 app/values/blacklight/types.rb
blacklight-7.31.0 app/values/blacklight/types.rb
blacklight-7.30.0 app/values/blacklight/types.rb
blacklight-7.29.0 app/values/blacklight/types.rb
blacklight-7.28.0 app/values/blacklight/types.rb
blacklight-7.27.1 app/values/blacklight/types.rb
blacklight-7.27.0 app/values/blacklight/types.rb
blacklight-7.26.1 app/values/blacklight/types.rb
blacklight-7.26.0 app/values/blacklight/types.rb
blacklight-7.25.3 app/values/blacklight/types.rb
blacklight-7.25.2 app/values/blacklight/types.rb
blacklight-7.25.1 app/values/blacklight/types.rb
blacklight-7.25.0 app/values/blacklight/types.rb
blacklight-7.24.0 app/values/blacklight/types.rb
blacklight-7.23.0.1 app/values/blacklight/types.rb
blacklight-7.23.0 app/values/blacklight/types.rb
blacklight-7.22.2 app/values/blacklight/types.rb
blacklight-7.22.1 app/values/blacklight/types.rb