Sha256: b07da79ab493514ff2577619fd083d67d2bcf75e66343b9e5c5bc1c490f5bd71

Contents?: true

Size: 523 Bytes

Versions: 12

Compression:

Stored size: 523 Bytes

Contents

module Spotlight
  # A configurable solr filter for the exhibit
  class Filter < ActiveRecord::Base
    belongs_to :exhibit

    validates :field, :value, presence: true

    def to_hash
      return {} unless field

      { field => cast_value }
    end

    private

    def cast_value
      return value unless field

      if field.ends_with? Spotlight::Engine.config.solr_fields.boolean_suffix
        ActiveRecord::Type::Boolean.new.type_cast_from_database(value)
      else
        value
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
blacklight-spotlight-0.20.3 app/models/spotlight/filter.rb
blacklight-spotlight-0.20.2 app/models/spotlight/filter.rb
blacklight-spotlight-0.20.1 app/models/spotlight/filter.rb
blacklight-spotlight-0.20.0 app/models/spotlight/filter.rb
blacklight-spotlight-0.19.2 app/models/spotlight/filter.rb
blacklight-spotlight-0.19.1 app/models/spotlight/filter.rb
blacklight-spotlight-0.19.0 app/models/spotlight/filter.rb
blacklight-spotlight-0.18.0 app/models/spotlight/filter.rb
blacklight-spotlight-0.17.1 app/models/spotlight/filter.rb
blacklight-spotlight-0.17.0 app/models/spotlight/filter.rb
blacklight-spotlight-0.16.0 app/models/spotlight/filter.rb
blacklight-spotlight-0.15.0 app/models/spotlight/filter.rb