Class: Geoblacklight::HeaderIconsComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/geoblacklight/header_icons_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(document:, fields: [Geoblacklight.configuration.fields.resource_class, Geoblacklight.configuration.fields.access_rights]) ⇒ HeaderIconsComponent

Returns a new instance of HeaderIconsComponent.



7
8
9
10
11
12
13
# File 'app/components/geoblacklight/header_icons_component.rb', line 7

def initialize(document:,
  fields: [Geoblacklight.configuration.fields.resource_class,
    Geoblacklight.configuration.fields.access_rights])
  @document = document
  @fields = fields
  super()
end

Instance Attribute Details

#documentObject (readonly)

Returns the value of attribute document.



5
6
7
# File 'app/components/geoblacklight/header_icons_component.rb', line 5

def document
  @document
end

#fieldsObject (readonly)

Returns the value of attribute fields.



5
6
7
# File 'app/components/geoblacklight/header_icons_component.rb', line 5

def fields
  @fields
end

Instance Method Details

#badge_class(field) ⇒ Object



19
20
21
22
23
24
25
# File 'app/components/geoblacklight/header_icons_component.rb', line 19

def badge_class(field)
  if field == Geoblacklight.configuration.fields.resource_class
    Geoblacklight::ResourceHeaderBadgeComponent
  else
    Geoblacklight::HeaderBadgeComponent
  end
end

#render_badge(field) ⇒ Object



15
16
17
# File 'app/components/geoblacklight/header_icons_component.rb', line 15

def render_badge(field)
  render badge_class(field).new(document: @document, field:)
end