Module: Wardrobe::Plugins::HtmlInitializer::InstanceMethods

Defined in:
lib/wardrobe/plugins/html_initializer.rb

Instance Method Summary collapse

Instance Method Details

#initialize(html = nil, **args) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/wardrobe/plugins/html_initializer.rb', line 22

def initialize(html = nil, **args)
  if html
    define_singleton_method(:_attribute_init) do |atr, doc, _name|
      value = atr.options[:html_selector].call(doc, atr, self)
      send(atr.setter_name, value)
    end
    html = HtmlInitializer.parse(html) if html.is_a?(String)
    _wardrobe_init(html)
  else
    super(**args)
  end
end