Class: SolidusAdmin::Products::Status::Component
- Inherits:
-
BaseComponent
- Object
- BaseComponent
- SolidusAdmin::Products::Status::Component
- Defined in:
- app/components/solidus_admin/products/status/component.rb
Constant Summary collapse
- COLORS =
{ available: :green, discontinued: :red }.freeze
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(product:) ⇒ Component
constructor
A new instance of Component.
-
#status ⇒ Symbol
:available when the product is available :discontinued when the product is not available.
Constructor Details
#initialize(product:) ⇒ Component
Returns a new instance of Component.
10 11 12 |
# File 'app/components/solidus_admin/products/status/component.rb', line 10 def initialize(product:) @product = product end |
Instance Method Details
#call ⇒ Object
14 15 16 17 18 19 |
# File 'app/components/solidus_admin/products/status/component.rb', line 14 def call render component('ui/badge').new( name: t(".#{status}"), color: COLORS.fetch(status) ) end |
#status ⇒ Symbol
Returns :available when the product is available :discontinued when the product is not available.
24 25 26 27 28 29 30 |
# File 'app/components/solidus_admin/products/status/component.rb', line 24 def status if @product.available? :available else :discontinued end end |