Class: Card::Bootstrap::Component

Inherits:
Object
  • Object
show all
Extended by:
ComponentKlass
Includes:
BasicTags, Delegate
Defined in:
lib/card/bootstrap/component.rb,
lib/card/bootstrap/component/form.rb,
lib/card/bootstrap/component/panel.rb,
lib/card/bootstrap/component/layout.rb,
lib/card/bootstrap/component/carousel.rb,
lib/card/bootstrap/component/horizontal_form.rb

Overview

render components of bootstrap library

Direct Known Subclasses

Carousel, Form, OldComponent

Defined Under Namespace

Classes: Carousel, Form, HorizontalForm, Layout, Panel

Instance Method Summary collapse

Methods included from ComponentKlass

def_div_method, def_tag_method

Methods included from Delegate

#method_missing, #respond_to_missing?

Methods included from BasicTags

#html

Constructor Details

#initialize(context, *args, &block) ⇒ Component

Returns a new instance of Component.



7
8
9
10
11
12
13
14
15
16
# File 'lib/card/bootstrap/component.rb', line 7

def initialize context, *args, &block
  @context = context
  @content = ["".html_safe]
  @args = args
  @child_args = []
  @append = []
  @wrap = []
  @build_block = block
  @html = Builder::XmlMarkup.new
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Card::Bootstrap::Delegate

Instance Method Details

#append(&block) ⇒ Object



32
33
34
# File 'lib/card/bootstrap/component.rb', line 32

def append &block
  @append[-1] << block
end

#cardObject



40
41
42
# File 'lib/card/bootstrap/component.rb', line 40

def card
  @context.context.card
end

#insert(&block) ⇒ Object



28
29
30
# File 'lib/card/bootstrap/component.rb', line 28

def insert &block
  instance_exec(&block)
end

#prepend(&block) ⇒ Object



22
23
24
25
26
# File 'lib/card/bootstrap/component.rb', line 22

def prepend &block
  tmp = @content.pop
  instance_exec(&block)
  @content << tmp
end

#renderObject



18
19
20
# File 'lib/card/bootstrap/component.rb', line 18

def render
  @rendered = render_content
end

#wrap(tag = nil, &block) ⇒ Object



36
37
38
# File 'lib/card/bootstrap/component.rb', line 36

def wrap tag=nil, &block
  @wrap[-1] << (block_given? ? block : tag)
end