Class: Spree::Filters::PropertyPresenter

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/spree/filters/property_presenter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(property:, product_properties:) ⇒ PropertyPresenter

Returns a new instance of PropertyPresenter.



4
5
6
7
# File 'app/presenters/spree/filters/property_presenter.rb', line 4

def initialize(property:, product_properties:)
  @property = property
  @product_properties = product_properties
end

Instance Attribute Details

#product_propertiesObject (readonly)

Returns the value of attribute product_properties.



9
10
11
# File 'app/presenters/spree/filters/property_presenter.rb', line 9

def product_properties
  @product_properties
end

Instance Method Details

#to_hObject



17
18
19
20
21
22
23
24
# File 'app/presenters/spree/filters/property_presenter.rb', line 17

def to_h
  {
    id: property.id,
    name: property.name,
    presentation: property.presentation,
    values: values_hash
  }
end

#uniq_valuesObject



13
14
15
# File 'app/presenters/spree/filters/property_presenter.rb', line 13

def uniq_values
  property.uniq_values(product_properties_scope: product_properties)
end