Class: Cms::AbstractFileBlock

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/cms/abstract_file_block.rb

Direct Known Subclasses

FileBlock, ImageBlock

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.publishable?Boolean


29
30
31
# File 'app/models/cms/abstract_file_block.rb', line 29

def self.publishable?
  true
end

Instance Method Details

#file_sizeObject

Exists here so FileBrowser can polymorphically call file_size on Page, Images, Files, etc.


21
22
23
# File 'app/models/cms/abstract_file_block.rb', line 21

def file_size
  file.size.round_bytes
end

#parentCms::Section

Return the parent section for this block.


16
17
18
# File 'app/models/cms/abstract_file_block.rb', line 16

def parent
  file.parent
end

#pathObject


25
26
27
# File 'app/models/cms/abstract_file_block.rb', line 25

def path
  file.url
end

#set_attachment_pathObject


33
34
35
36
37
# File 'app/models/cms/abstract_file_block.rb', line 33

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

#set_attachment_sectionObject


39
40
41
42
43
# File 'app/models/cms/abstract_file_block.rb', line 39

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