Sha256: bfd07d26e4f4e83822470245f30ad900609c26428aeb0baa87a8f9e3546228d9

Contents?: true

Size: 727 Bytes

Versions: 3

Compression:

Stored size: 727 Bytes

Contents

module Spree::Cms::Sections
  class FeaturedArticle < Spree::CmsSection
    before_save :reset_link_attributes
    after_initialize :default_values

    store :content, accessors: [:title, :subtitle, :button_text, :rte_content], coder: JSON
    store :settings, accessors: [:gutters], coder: JSON

    LINKED_RESOURCE_TYPE = ['Spree::Taxon', 'Spree::Product', 'Spree::CmsPage']

    def gutters?
      gutters == 'Gutters'
    end

    private

    def reset_link_attributes
      if linked_resource_type_changed?
        self.linked_resource_id = nil
      end
    end

    def default_values
      self.gutters ||= 'No Gutters'
      self.fit ||= 'Screen'
      self.linked_resource_type ||= 'Spree::Taxon'
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spree_core-4.3.0.rc3 app/models/spree/cms/sections/featured_article.rb
spree_core-4.3.0.rc2 app/models/spree/cms/sections/featured_article.rb
spree_core-4.3.0.rc1 app/models/spree/cms/sections/featured_article.rb