Module: WkHtml::Settings

Included in:
ToImage::GlobalSettings, ToPdf::GlobalSettings, ToPdf::ObjectSettings
Defined in:
lib/wkhtml/settings.rb

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

TRUE =
'true'
FALSE =
'false'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



6
7
8
# File 'lib/wkhtml/settings.rb', line 6

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#initialize(initial = {}) ⇒ Object



10
11
12
13
# File 'lib/wkhtml/settings.rb', line 10

def initialize(initial = {})
  initial = self.class.default_settings.merge(initial)
  initial.each{|key,value| self[key] = value}
end

#to_hashObject Also known as: to_h

Convert all attributes to Hash. This will ignore errors from retrieving the setting.



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/wkhtml/settings.rb', line 19

def to_hash()
  Hash[
    self.class.settings.map do |key|
      begin
        [key, self[key]]
      rescue ArgumentError
        nil
      end
    end.compact()
  ]
end