Class: Ddr::Index::Field

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/ddr/index/field.rb

Direct Known Subclasses

UniqueKeyField

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base, *args) ⇒ Field

Returns a new instance of Field.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/ddr/index/field.rb', line 8

def initialize(base, *args)
  @base = base.to_s
  name = if args.empty?
           @base
         elsif args.last.is_a?(Hash) && args.last[:solr_name]
           args.last[:solr_name]
         else
           Solrizer.solr_name(base, *args)
         end
  super(name)
end

Instance Attribute Details

#baseObject (readonly)

Returns the value of attribute base.



6
7
8
# File 'lib/ddr/index/field.rb', line 6

def base
  @base
end

Instance Method Details

#headingObject



24
25
26
# File 'lib/ddr/index/field.rb', line 24

def heading
  I18n.t "#{i18n_base}.heading", default: base
end

#labelObject



20
21
22
# File 'lib/ddr/index/field.rb', line 20

def label
  I18n.t "#{i18n_base}.label", default: base.titleize
end