Sha256: 4170230c9450b1fdef17e50fd4d981754dca4a4fdc746eb27b8c8c4e3d932222

Contents?: true

Size: 645 Bytes

Versions: 3

Compression:

Stored size: 645 Bytes

Contents

module Blocky
  class ContentBlock < ActiveRecord::Base
    before_save :tidy_content

    scope :global,   -> { where("controller IS NULL AND action IS NULL") }
    scope :per_page, -> { where("controller IS NOT NULL AND action IS NOT NULL") }

    def global?
      self.controller.nil? && self.action.nil?
    end

    def tidy_content
      tidy = Tidy.new({
        doctype: "omit",
        indent: "auto",
        indent_spaces: 2,
        markup: true,
        output_xhtml: true,
        show_body_only: "yes",
        tab_size: 2,
        tidy_mark: false
      })
      self.content = tidy.clean(self.content.strip)
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
blocky-0.0.3 app/models/blocky/content_block.rb
blocky-0.0.2 app/models/blocky/content_block.rb
blocky-0.0.1 app/models/blocky/content_block.rb