Method: BBLib::HTML::Tag#method_missing

Defined in:
lib/bblib/html/tag.rb

#method_missing(method, *args, &block) ⇒ Object (protected)



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/bblib/html/tag.rb', line 91

def method_missing(method, *args, &block)
  if context && context.respond_to?(method)
    context.send(method, *args, &block)
  elsif method != :to_ary
    if method.to_s.encap_by?('_')
      self.set_attribute(:id, method.to_s.uncapsulate('_'))
    else
      klass = method.to_s.gsub(/(?<=[^\_])\_(?=[^\_])/, '-').gsub('__', '_')
      self.append_attribute(:class, klass)
    end
    self._initialize(type, *args, &block)
    self
  else
    super
  end
end