Sha256: f5beb0232136aa31525debd0a75a4e63e32654f35ec80bfe48bb831444bd227d

Contents?: true

Size: 1.15 KB

Versions: 4

Compression:

Stored size: 1.15 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,
      :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

4 entries across 4 versions & 1 rubygems

Version Path
knitkit-2.1.3 app/models/online_document_section.rb
knitkit-2.1.2 app/models/online_document_section.rb
knitkit-2.1.1 app/models/online_document_section.rb
knitkit-2.1.0 app/models/online_document_section.rb