Class: Workarea::Storefront::ProductViewModel::Option
- Inherits:
-
Object
- Object
- Workarea::Storefront::ProductViewModel::Option
- Defined in:
- app/view_models/workarea/storefront/product_view_model/option.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#product ⇒ Object
readonly
Returns the value of attribute product.
-
#selections ⇒ Object
readonly
Returns the value of attribute selections.
-
#slug ⇒ Object
readonly
Returns the value of attribute slug.
Instance Method Summary collapse
- #current ⇒ Object
-
#initialize(product, slug, selections, options = {}) ⇒ Option
constructor
A new instance of Option.
- #name ⇒ Object
Constructor Details
#initialize(product, slug, selections, options = {}) ⇒ Option
Returns a new instance of Option.
7 8 9 10 11 12 |
# File 'app/view_models/workarea/storefront/product_view_model/option.rb', line 7 def initialize(product, slug, selections, = {}) @product = product @slug = slug.optionize @selections = selections @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'app/view_models/workarea/storefront/product_view_model/option.rb', line 5 def @options end |
#product ⇒ Object (readonly)
Returns the value of attribute product.
5 6 7 |
# File 'app/view_models/workarea/storefront/product_view_model/option.rb', line 5 def product @product end |
#selections ⇒ Object (readonly)
Returns the value of attribute selections.
5 6 7 |
# File 'app/view_models/workarea/storefront/product_view_model/option.rb', line 5 def selections @selections end |
#slug ⇒ Object (readonly)
Returns the value of attribute slug.
5 6 7 |
# File 'app/view_models/workarea/storefront/product_view_model/option.rb', line 5 def slug @slug end |
Instance Method Details
#current ⇒ Object
18 19 20 |
# File 'app/view_models/workarea/storefront/product_view_model/option.rb', line 18 def current [slug].presence_in(selections) end |
#name ⇒ Object
14 15 16 |
# File 'app/view_models/workarea/storefront/product_view_model/option.rb', line 14 def name slug.titleize end |