Sha256: 188a53a1fab65b7f7d622f64eaf111dc9fe79bb3ff4b431e61b16d180a7ffcbc

Contents?: true

Size: 1.19 KB

Versions: 6

Compression:

Stored size: 1.19 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
  
  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,
      :use_markdown => self.use_markdown,
      :type => self.class.to_s,
      :in_menu => self.in_menu,
      :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

6 entries across 6 versions & 1 rubygems

Version Path
knitkit-2.1.9 app/models/online_document_section.rb
knitkit-2.1.8 app/models/online_document_section.rb
knitkit-2.1.7 app/models/online_document_section.rb
knitkit-2.1.6 app/models/online_document_section.rb
knitkit-2.1.5 app/models/online_document_section.rb
knitkit-2.1.4 app/models/online_document_section.rb