Sha256: e71ba312fb2e9a9cfe68348c4ba733d322c8dd2d51752e4defab354c2b65ea1e

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

require 'caracal/core/models/page_flip_model'
require 'caracal/errors'


module Caracal
  module Core

    # This module encapsulates all the functionality related to flipping
    # specific page contents
    #
    module PageFlips
      def self.included(base)
        base.class_eval do

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

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

            # Pass through the page dimensions from the parent document,
            # using the page height as the page width, due to it using
            # the inverse dimensions.
            options.merge!({
              width: page_height,
              margin_left: page_margin_left,
              margin_right: page_margin_right
            })

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

            model
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
caracal_the_curve-1.4.6 lib/caracal/core/page_flips.rb
caracal_the_curve-1.4.5 lib/caracal/core/page_flips.rb