Sha256: 154dc9ea0381fdbc27bf56f7dcb91d8c8b9b2f4c532176c28ff0bac21ad712a0

Contents?: true

Size: 1.33 KB

Versions: 11

Compression:

Stored size: 1.33 KB

Contents

module CamaleonCms
  module Widget
    class Main < CamaleonCms::TermTaxonomy
      default_scope { where(taxonomy: :widget) }
      # attr_accessible :excerpt, :renderer
      # name: "title"
      # description: "content for this"
      # slug: "key for this"
      # status = simple or complex (default)
      # excerpt: string for message
      # renderer: string (path to the template for render this widget)

      has_many :metas, lambda {
                         where(object_class: 'Widget::Main')
                       }, class_name: 'CamaleonCms::Meta', foreign_key: :objectid, dependent: :destroy
      belongs_to :owner, class_name: CamaManager.get_user_class_name, foreign_key: :user_id
      belongs_to :site, class_name: 'CamaleonCms::Site', foreign_key: :parent_id

      has_many :assigned, class_name: 'CamaleonCms::Widget::Assigned', foreign_key: :visibility, dependent: :destroy
      before_save :check_excerpt
      def is_simple?
        status == 'simple'
      end

      attr_writer :excerpt, :renderer

      def excerpt
        get_option('excerpt')
      end

      def renderer
        get_option('renderer')
      end

      def short_code
        "[widget #{slug}]"
      end

      private

      def check_excerpt
        set_option('excerpt', @excerpt)
        set_option('renderer', @renderer)
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
camaleon_cms-2.9.0 app/models/camaleon_cms/widget/main.rb
camaleon_cms-2.8.3 app/models/camaleon_cms/widget/main.rb
camaleon_cms-2.8.2 app/models/camaleon_cms/widget/main.rb
camaleon_cms-2.8.1 app/models/camaleon_cms/widget/main.rb
camaleon_cms-2.8.0 app/models/camaleon_cms/widget/main.rb
camaleon_cms-2.7.5 app/models/camaleon_cms/widget/main.rb
camaleon_cms-2.7.4 app/models/camaleon_cms/widget/main.rb
camaleon_cms-2.7.3 app/models/camaleon_cms/widget/main.rb
camaleon_cms-2.7.2 app/models/camaleon_cms/widget/main.rb
camaleon_cms-2.7.1 app/models/camaleon_cms/widget/main.rb
camaleon_cms-2.7.0 app/models/camaleon_cms/widget/main.rb