Module: Spree::PageBuilder::TaxonDecorator
- Defined in:
- app/models/spree/page_builder/taxon_decorator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #featured? ⇒ Boolean
- #featured_sections ⇒ Object
- #page_builder_image ⇒ Object
- #page_builder_url ⇒ Object
Class Method Details
.prepended(base) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'app/models/spree/page_builder/taxon_decorator.rb', line 4 def self.prepended(base) base.include Spree::Linkable base.class_eval do after_commit :touch_featured_sections, on: [:update] after_touch :touch_featured_sections after_destroy :remove_featured_sections, if: -> { featured? } end end |
Instance Method Details
#featured? ⇒ Boolean
24 25 26 |
# File 'app/models/spree/page_builder/taxon_decorator.rb', line 24 def featured? featured_sections.any? end |
#featured_sections ⇒ Object
28 29 30 |
# File 'app/models/spree/page_builder/taxon_decorator.rb', line 28 def featured_sections @featured_sections ||= Spree::PageSections::FeaturedTaxon.published.by_taxon_id(id) end |
#page_builder_image ⇒ Object
20 21 22 |
# File 'app/models/spree/page_builder/taxon_decorator.rb', line 20 def page_builder_image square_image.presence || image end |