Module: Caracal::Core::TableOfContents

Included in:
Document
Defined in:
lib/caracal/core/table_of_contents.rb

Overview

This module encapsulates all the functionality related to table of contents

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/caracal/core/table_of_contents.rb', line 12

def self.included(base)
  base.class_eval do

    #-------------------------------------------------------------
    # Public Methods
    #-------------------------------------------------------------

    def table_of_contents(*args, &block)
      options = Caracal::Utilities.extract_options!(args)

      model = Caracal::Core::Models::TableOfContentsModel.new(options, &block)
      
      if model.valid?
        contents << model
      end

      model
    end
  end
end