Module: ClockworkComicPDF::OptionValidation

Included in:
Book, Cover, PageHeader, Section, Sections, Version
Defined in:
lib/clockwork_comic_pdf/option_validation.rb

Overview

provides option validation and requirements vaildaiton

Instance Method Summary collapse

Instance Method Details

#check_options(options, valid_options) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/clockwork_comic_pdf/option_validation.rb', line 7

def check_options(options, valid_options)
  options.each do |key|
    unless valid_options.include? key
      fail UndefinedKeyError, "Unsupported key '#{key}' " <<
                              "for '#{self.class}'"
    end
  end
end

#check_required(options = {}) ⇒ Object



16
17
18
19
20
21
# File 'lib/clockwork_comic_pdf/option_validation.rb', line 16

def check_required(options = {})
  options.each_pair do |key, val|
    fail UndefinedKeyError, "'#{self.class}' requires " <<
                            "key '#{key}'" if val.nil?
  end
end