app/models/spotlight/blacklight_configuration.rb in blacklight-spotlight-0.34.1 vs app/models/spotlight/blacklight_configuration.rb in blacklight-spotlight-1.0.0.alpha1

- old
+ new

@@ -3,11 +3,11 @@ module Spotlight ## # Exhibit-specific blacklight configuration model # rubocop:disable Metrics/ClassLength class BlacklightConfiguration < ActiveRecord::Base - belongs_to :exhibit, touch: true + belongs_to :exhibit, touch: true, optional: true serialize :facet_fields, Hash serialize :index_fields, Hash serialize :search_fields, Hash serialize :sort_fields, Hash serialize :default_solr_params, Hash @@ -196,25 +196,26 @@ end end # rubocop:enable Metrics/MethodLength, Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity def custom_index_fields - Hash[exhibit.custom_fields.map do |x| + Hash[exhibit.custom_fields.reject(&:new_record?).map do |x| field = Blacklight::Configuration::IndexField.new x.configuration.merge( key: x.field, field: x.solr_field, custom_field: true ) [x.field, field] end] end def custom_facet_fields - Hash[exhibit.custom_fields.vocab.map do |x| + Hash[exhibit.custom_fields.vocab.reject(&:new_record?).map do |x| field = Blacklight::Configuration::FacetField.new x.configuration.merge( key: x.field, field: x.solr_field, show: false, custom_field: true ) field.if = :field_enabled? field.enabled = false + field.limit = true [x.field, field] end] end ## @@ -342,16 +343,9 @@ 100 + (fields.keys.index(index) || fields.keys.length) end end def value_to_boolean(v) - if defined? ActiveModel::Type::Boolean - ActiveModel::Type::Boolean.new.cast v - elsif defined? ActiveRecord::Type::Boolean - # Rails 4.2+ - ActiveRecord::Type::Boolean.new.type_cast_from_database v - else - ActiveRecord::ConnectionAdapters::Column.value_to_boolean v - end + ActiveModel::Type::Boolean.new.cast v end end end