Class: CodengageViewComponents::ItemComponent

Inherits:
ApplicationComponent show all
Defined in:
app/components/codengage_view_components/item_component.rb

Instance Method Summary collapse

Constructor Details

#initialize(value:, url:, method: :get, icon: nil, options: {}) ⇒ ItemComponent

Returns a new instance of ItemComponent.



5
6
7
8
9
10
11
# File 'app/components/codengage_view_components/item_component.rb', line 5

def initialize(value:, url:, method: :get, icon: nil, options: {})
  @value = value
  @url = url
  @method = method
  @icon = icon
  @options = options
end

Instance Method Details

#data_attributesObject



13
14
15
# File 'app/components/codengage_view_components/item_component.rb', line 13

def data_attributes
  @options.fetch(:data, {})
end

#delete?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'app/components/codengage_view_components/item_component.rb', line 29

def delete?
  @method.to_s == "delete"
end

#icon_sizeObject



25
26
27
# File 'app/components/codengage_view_components/item_component.rb', line 25

def icon_size
  @options.fetch(:icon_size, "")
end

#icon_strokeObject



21
22
23
# File 'app/components/codengage_view_components/item_component.rb', line 21

def icon_stroke
  @options.fetch(:icon_stroke, "gray")
end

#text_classObject



17
18
19
# File 'app/components/codengage_view_components/item_component.rb', line 17

def text_class
  @options.fetch(:text_class, "")
end