Class: Blacklight::Configuration::Field
Instance Attribute Summary collapse
Instance Method Summary
collapse
#deep_dup, #deep_transform_values, #merge, #merge!, #reverse_merge, #select, #sort_by, #sort_by!, #to_h, #try
Instance Attribute Details
#field ⇒ String
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/blacklight/configuration/field.rb', line 18
def normalize! _blacklight_config = nil
self.field ||= key
self.key ||= self.field
self.label ||= default_label
self.if = true if self.if.nil?
self.unless = false if self.unless.nil?
self.field &&= self.field.to_s
self
end
|
#if ⇒ Proc, Symbol
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/blacklight/configuration/field.rb', line 18
def normalize! _blacklight_config = nil
self.field ||= key
self.key ||= self.field
self.label ||= default_label
self.if = true if self.if.nil?
self.unless = false if self.unless.nil?
self.field &&= self.field.to_s
self
end
|
#key ⇒ String
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/blacklight/configuration/field.rb', line 18
def normalize! _blacklight_config = nil
self.field ||= key
self.key ||= self.field
self.label ||= default_label
self.if = true if self.if.nil?
self.unless = false if self.unless.nil?
self.field &&= self.field.to_s
self
end
|
#label ⇒ String, Symbol
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/blacklight/configuration/field.rb', line 18
def normalize! _blacklight_config = nil
self.field ||= key
self.key ||= self.field
self.label ||= default_label
self.if = true if self.if.nil?
self.unless = false if self.unless.nil?
self.field &&= self.field.to_s
self
end
|
#unless ⇒ Proc, Symbol
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/blacklight/configuration/field.rb', line 18
def normalize! _blacklight_config = nil
self.field ||= key
self.key ||= self.field
self.label ||= default_label
self.if = true if self.if.nil?
self.unless = false if self.unless.nil?
self.field &&= self.field.to_s
self
end
|
Instance Method Details
#default_label ⇒ Object
46
47
48
49
50
51
52
|
# File 'lib/blacklight/configuration/field.rb', line 46
def default_label
if self.key.respond_to?(:titleize)
self.key.titleize
else
self.key.to_s.titleize
end
end
|
#display_label(context = nil, **options) ⇒ Object
36
37
38
39
40
41
42
43
44
|
# File 'lib/blacklight/configuration/field.rb', line 36
def display_label(context = nil, **options)
field_label(
(:"blacklight.search.fields.#{context}.#{key}" if context),
:"blacklight.search.fields.#{key}",
label,
default_label,
**options
)
end
|
#normalize!(_blacklight_config = nil) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/blacklight/configuration/field.rb', line 18
def normalize! _blacklight_config = nil
self.field ||= key
self.key ||= self.field
self.label ||= default_label
self.if = true if self.if.nil?
self.unless = false if self.unless.nil?
self.field &&= self.field.to_s
self
end
|
#validate! ⇒ Object
32
33
34
|
# File 'lib/blacklight/configuration/field.rb', line 32
def validate!
raise ArgumentError, "Must supply a field name" if self.field.nil?
end
|