Module: TwitterBootstrapMarkup::ButtonBase

Included in:
Button, LinkButton
Defined in:
lib/twitter_bootstrap_markup/button_base.rb

Constant Summary collapse

TYPES =
[:primary, :info, :success, :warning, :danger, :inverse]
SIZES =
[:large, :small, :mini]

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/twitter_bootstrap_markup/button_base.rb', line 6

def self.included(base)

  TYPES.each do |type|
    base.send(:define_method, type) do
      attributes.append!(:class, "btn-#{type}")
      self
    end
  end

  SIZES.each do |size|
    base.send(:define_method, size) do
      self.attributes.append!(:class, "btn-#{size}")
      self
    end
  end

  TYPES.each do |type|
    base.send(:define_singleton_method, type) do |*args, &block|
      self.new(*args, &block).send(type)
    end
  end

  SIZES.each do |size|
    base.send(:define_singleton_method, size) do |*args, &block|
      self.new(*args, &block).send(size)
    end
  end

  TYPES.each do |type|
    SIZES.each do |size|
      base.send(:define_singleton_method, "#{type}_#{size}") do |*args, &block|
        self.new(*args, &block).send(type).send(size)
      end
    end
  end

end