Module: Caracal::Core::IFrames

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

Overview

This module encapsulates all the functionality related to inserting word document snippets into the document.

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
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/caracal/core/iframes.rb', line 12

def self.included(base)
  base.class_eval do

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

    def iframe(options={}, &block)
      model = Caracal::Core::Models::IFrameModel.new(options, &block)
      if model.valid?
        model.preprocess!

        # table cells can't hold namespaces; the document
        # collects those when it renders.
        if respond_to?(:namespace)
          model.namespaces.each do |(prefix, href)|
            namespace({ prefix: prefix, href: href })
          end
          model.ignorables.each do |prefix|
            ignorable(prefix)
          end
        end

        contents << model
      else
        raise Caracal::Errors::InvalidModelError, 'IFrameModel requires either the :url or :data argument.'
      end
      model
    end

  end
end