Sha256: 00b7e7f3532ad10c33df5f1237673d695428cf2df8719b206d868a49ecaaad2a

Contents?: true

Size: 1.35 KB

Versions: 10

Compression:

Stored size: 1.35 KB

Contents

class OnlineDocumentSection < WebsiteSection
  has_one :documented_item, :dependent => :destroy
  delegate :content, :to => :documented_item, :prefix => true
  delegate :published_content, :to => :documented_item, :prefix => true
  has_permalink :title, :url_attribute => :permalink, :sync_url => true, :only_when_blank => true, :scope => [:website_id, :parent_id]
  
  def documented_item_content_html
    documented_item_content.body_html
  rescue
    nil
  end
  
  def documented_item_published_content_html(active_publication)
    documented_item_published_content(active_publication).body_html
  rescue
    nil
  end
  
  def build_section_hash
    section_hash = {
      :name => self.title,
      :has_layout => false,
      :type => self.class.to_s,
      :in_menu => self.in_menu,
      :roles => self.roles.collect{|role| role.internal_identifier},
      :path => self.path,
      :permalink => self.permalink,
      :internal_identifier => self.internal_identifier,
      :position => self.position,
      :online_document_sections => self.children.each.map{|child| child.build_section_hash},
      :articles => [],
      :documented_item => {
        :name => documented_item_content.title,
        :display_title => documented_item_content.display_title,
        :internal_identifier => documented_item_content.internal_identifier
      }
    }
    section_hash
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
knitkit-2.0.11 app/models/online_document_section.rb
knitkit-2.0.10 app/models/online_document_section.rb
knitkit-2.0.9 app/models/online_document_section.rb
knitkit-2.0.7 app/models/online_document_section.rb
knitkit-2.0.6 app/models/online_document_section.rb
knitkit-2.0.5 app/models/online_document_section.rb
knitkit-2.0.4 app/models/online_document_section.rb
knitkit-2.0.3 app/models/online_document_section.rb
knitkit-2.0.2 app/models/online_document_section.rb
knitkit-2.0.1 app/models/online_document_section.rb