Class: SolidusAdmin::Sidebar::Item::Component

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/solidus_admin/sidebar/item/component.rb

Overview

Menu item within a Sidebar

Instance Method Summary collapse

Constructor Details

#initialize(item:, fullpath: "#", url_helpers: Struct.new(:spree, :solidus_admin).new(spree, solidus_admin)) ⇒ Component

Returns a new instance of Component.

Parameters:

  • item (SolidusAdmin::MainNavItem)

    tem [SolidusAdmin::MainNavItem

  • fullpath (String) (defaults to: "#")

    the current path

  • url_helpers (#solidus_admin, #spree) (defaults to: Struct.new(:spree, :solidus_admin).new(spree, solidus_admin))

    context for generating paths



10
11
12
13
14
15
16
17
18
# File 'app/components/solidus_admin/sidebar/item/component.rb', line 10

def initialize(
  item:,
  fullpath: "#",
  url_helpers: Struct.new(:spree, :solidus_admin).new(spree, solidus_admin)
)
  @item = item
  @url_helpers = url_helpers
  @fullpath = fullpath
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'app/components/solidus_admin/sidebar/item/component.rb', line 24

def active?
  @item.active?(@url_helpers, @fullpath)
end

#pathObject



20
21
22
# File 'app/components/solidus_admin/sidebar/item/component.rb', line 20

def path
  @item.path(@url_helpers)
end