Sha256: 5f19e8877e091342678d5d49d24a33a6996ae32bc611a930db2569c3a09e7215

Contents?: true

Size: 589 Bytes

Versions: 31

Compression:

Stored size: 589 Bytes

Contents

module Blacklight
  class Configuration::Field < OpenStructWithHashAccess
    def normalize! blacklight_config = nil
      self.field ||= self.key
      self.key ||= self.field

      self.label ||= default_label

      self.if = true if self.if.nil?
      self.unless = false if self.unless.nil?

      self
    end
  
    def validate!
      raise ArgumentError.new("Must supply a field name") if self.field.nil?
    end

    def default_label
      if self.key.respond_to?(:titleize)
        self.key.try(:titleize)
      else
        self.key.to_s.titleize
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
blacklight-5.19.2 lib/blacklight/configuration/field.rb
blacklight-5.19.1 lib/blacklight/configuration/field.rb
blacklight-5.19.0 lib/blacklight/configuration/field.rb
blacklight-5.18.0 lib/blacklight/configuration/field.rb
blacklight-5.17.2 lib/blacklight/configuration/field.rb
blacklight-6.0.0.pre5 lib/blacklight/configuration/field.rb
blacklight-5.17.1 lib/blacklight/configuration/field.rb
blacklight-5.17.0 lib/blacklight/configuration/field.rb
blacklight-6.0.0.pre4 lib/blacklight/configuration/field.rb
blacklight-5.16.4 lib/blacklight/configuration/field.rb
blacklight-6.0.0.pre3 lib/blacklight/configuration/field.rb
blacklight-5.16.3 lib/blacklight/configuration/field.rb
blacklight-5.16.2 lib/blacklight/configuration/field.rb
blacklight-5.16.1 lib/blacklight/configuration/field.rb
blacklight-6.0.0.pre2 lib/blacklight/configuration/field.rb
blacklight-6.0.0.pre1 app/models/blacklight/configuration/field.rb
blacklight-5.16.0 app/models/blacklight/configuration/field.rb
blacklight-5.15.0 lib/blacklight/configuration/field.rb
blacklight-5.14.0 lib/blacklight/configuration/field.rb
blacklight-5.13.1 lib/blacklight/configuration/field.rb