Sha256: 897b7bb9080bc6f290b5f80eaa08f4b31e33e8e525ae989162ccebc017ef2f9c
Contents?: true
Size: 909 Bytes
Versions: 1
Compression:
Stored size: 909 Bytes
Contents
module TwitterBootstrapMarkup class Alert < Tag TYPES = [:warning, :info, :success, :danger] def initialize(*args, &block) super(:div, *args, &block) attributes.prepend!(:class, 'alert') end TYPES.each do |type| define_method type do attributes.append!(:class, "alert-#{type}") unless type == :warning self end end def closable prepend Tag.new(:a, :class => 'close', 'data-dismiss' => 'alert') { append '×' } self end TYPES.each do |type| define_singleton_method type do |*args, &block| self.new(*args, &block).send(type) end define_singleton_method "#{type}_closable" do |*args, &block| self.new(*args, &block).send(type).closable end end def self.closable(*args, &block) self.new(*args, &block).closable end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
twitter_bootstrap_markup-0.0.3 | lib/twitter_bootstrap_markup/alert.rb |