Sha256: 620908756aa86b82de4e41e72e3e5c5b35a7b2489207440f83d8cdffc7eea0bb
Contents?: true
Size: 1.64 KB
Versions: 19
Compression:
Stored size: 1.64 KB
Contents
require 'caracal/core/models/page_number_model' require 'caracal/errors' module Caracal module Core # This module encapsulates all the functionality related to setting the # document's page number behavior. # module PageNumbers def self.included(base) base.class_eval do #------------------------------------------------------------- # Configuration #------------------------------------------------------------- # constants const_set(:DEFAULT_PAGE_NUMBER_ALIGN, :center) # accessors attr_reader :page_number_show attr_reader :page_number_align #------------------------------------------------------------- # Public Methods #------------------------------------------------------------- # This method controls whether and how page numbers are displayed # on the document. # def page_numbers(*args, &block) options = Caracal::Utilities.extract_options!(args) options.merge!({ show: !!args.first }) unless args.first.nil? # careful: falsey value model = Caracal::Core::Models::PageNumberModel.new(options, &block) if model.valid? @page_number_show = model.page_number_show @page_number_align = model.page_number_align else raise Caracal::Errors::InvalidModelError, 'page_numbers :align parameter must be :left, :center, or :right' end end end end end end end
Version data entries
19 entries across 19 versions & 1 rubygems