Sha256: 6005b8c3c7d643efbbe1ca811df062beaf702fa9f4b3f5045699a953088b76ea

Contents?: true

Size: 1.21 KB

Versions: 3

Compression:

Stored size: 1.21 KB

Contents

class Card
  class Content
    # content-related methods for cards
    module All
      def content
        structured_content || standard_content
      end
      # alias_method :raw_content, :content # DEPRECATED!

      def content= value
        self.db_content = standardize_content value
      end

      def content?
        content.present?
      end

      def standard_content
        db_content || (new_card? && template.db_content)
      end

      def standardize_content value
        value.is_a?(Array) ? items_content(value) : value
      end

      def structured_content
        structure && template.db_content
      end

      def refresh_content
        self.content = Card.find(id)&.db_content
      end

      def save_content_draft _content
        clear_drafts
      end

      def clear_drafts
        drafts.created_by(Card::Auth.current_id).each(&:delete)
      end

      def last_draft_content
        drafts.last.card_changes.last.value
      end

      def blank_content?
        content.blank? || content.strip.blank?
      end

      def nests?
        content_object.has_chunk? Content::Chunk::Nest
      end

      def content_object
        Card::Content.new content, self
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
card-1.104.2 lib/card/content/all.rb
card-1.104.1 lib/card/content/all.rb
card-1.104.0 lib/card/content/all.rb