Sha256: 265feeec0061a0f42379329d824efa9a8a5ca9d153932ddc46330a3ac42e175c

Contents?: true

Size: 716 Bytes

Versions: 2

Compression:

Stored size: 716 Bytes

Contents

module Pulitzer
  class PostTypeContentElementType < ActiveRecord::Base
    include Pulitzer::PostTypeElement
    
    belongs_to :post_type
    belongs_to :content_element_type
    has_one :content_element
    before_save :handle_sort_order

    delegate :type, :image_type?, to: :content_element_type

    default_scope { order(sort_order: :asc) }

    validates :label, presence: true

    def type_specific_display
      case type
      when :image
        "#{height}x#{width}"
      when :text
        text_editor_display
      else
        ''
      end
    end

    def text_editor_display
      case text_editor
      when 'None'
        'no editor'
      else
        text_editor
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pulitzer-0.13.1 app/models/pulitzer/post_type_content_element_type.rb
pulitzer-0.13.0 app/models/pulitzer/post_type_content_element_type.rb