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.



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

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.



4
5
6
# File 'lib/ddr/index/field.rb', line 4

def base
  @base
end

Instance Method Details

#headingObject



22
23
24
# File 'lib/ddr/index/field.rb', line 22

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

#labelObject



18
19
20
# File 'lib/ddr/index/field.rb', line 18

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