Method: HtmlAttrs#initialize

Defined in:
lib/html_attrs.rb

#initialize(constructor = nil) ⇒ HtmlAttrs

Returns a new instance of HtmlAttrs.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/html_attrs.rb', line 11

def initialize(constructor = nil)
  if constructor.respond_to?(:to_hash)
    super()
    update(constructor)

    hash = constructor.is_a?(Hash) ? constructor : constructor.to_hash
    self.default = hash.default if hash.default
    self.default_proc = hash.default_proc if hash.default_proc
  elsif constructor.nil?
    super()
  else
    super(constructor)
  end
end