Sha256: 75cc85dd649fc70f3d8f224f6df76b38354b95db2f5ad221cdbf4c58421af02a

Contents?: true

Size: 953 Bytes

Versions: 6

Compression:

Stored size: 953 Bytes

Contents

module Cms
  class AbstractFileBlock < ActiveRecord::Base


    set_table_name Namespacing.prefix("file_blocks")

    validates_presence_of :name

    scope :by_section, lambda { |section| {
            :include => {:attachment => :section_node },
            :conditions => ["#{SectionNode.table_name}.ancestry = ?", section.node.ancestry_path] }
        }

    # Return the parent section for this block.
    # @return [Cms::Section]
    def parent
      attachment.parent
    end

    def path
      attachment_file_path
    end

    def self.publishable?
      true
    end

    def set_attachment_path
      if @attachment_file_path && @attachment_file_path != attachment.file_path
        attachment.file_path = @attachment_file_path
      end
    end

    def set_attachment_section
      if @attachment_section_id && @attachment_section_id != attachment.section
        attachment.section_id = @attachment_section_id
      end
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
browsercms-3.4.2 app/models/cms/abstract_file_block.rb
browsercms-3.4.2.rc1 app/models/cms/abstract_file_block.rb
browsercms-3.4.1 app/models/cms/abstract_file_block.rb
browsercms-3.4.0 app/models/cms/abstract_file_block.rb
browsercms-3.4.0.rc2 app/models/cms/abstract_file_block.rb
browsercms-3.4.0.rc1 app/models/cms/abstract_file_block.rb