Class: Card::Bootstrap::OldComponent
- Defined in:
- lib/card/bootstrap/old_component.rb
Overview
not-yet-obviated component handling
Direct Known Subclasses
Class Method Summary collapse
-
.add_div_method(name, html_class, opts = {}, &tag_block) ⇒ Object
(also: def_div_method)
Like add_tag_method but always generates a div tag The tag option is not available.
-
.add_tag_method(name, html_class, tag_opts = {}, &tag_block) ⇒ Object
(also: def_tag_method)
Defines a method that generates a html tag.
- .render(format, *args, &block) ⇒ Object
Instance Method Summary collapse
-
#initialize(context, *args, &block) ⇒ OldComponent
constructor
A new instance of OldComponent.
- #render ⇒ Object
Methods included from Delegate
#method_missing, #respond_to_missing?
Methods inherited from Component
#append, #card, #insert, #prepend, #wrap
Methods included from ComponentKlass
#def_div_method, #def_tag_method
Constructor Details
#initialize(context, *args, &block) ⇒ OldComponent
Returns a new instance of OldComponent.
7 8 9 10 11 12 13 14 15 |
# File 'lib/card/bootstrap/old_component.rb', line 7 def initialize context, *args, &block @context = context @content = ["".html_safe] @args = args @child_args = [] @append = [] @wrap = [] @build_block = block end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Card::Bootstrap::Delegate
Class Method Details
.add_div_method(name, html_class, opts = {}, &tag_block) ⇒ Object Also known as: def_div_method
Like add_tag_method but always generates a div tag The tag option is not available
24 25 26 |
# File 'lib/card/bootstrap/old_component.rb', line 24 def add_div_method name, html_class, opts={}, &tag_block add_tag_method name, html_class, opts.merge(tag: :div), &tag_block end |
.add_tag_method(name, html_class, tag_opts = {}, &tag_block) ⇒ Object Also known as: def_tag_method
Defines a method that generates a html tag
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/card/bootstrap/old_component.rb', line 39 def add_tag_method name, html_class, tag_opts={}, &tag_block define_method name do |*args, &block| process_tag tag_opts[:tag] || name do content, opts, new_child_args = standardize_args args, &tag_block add_classes opts, html_class, tag_opts.delete(:optional_classes) if (attributes = tag_opts.delete(:attributes)) opts.merge! attributes end content = with_child_args new_child_args do generate_content content, tag_opts[:content_processor], &block end [content, opts] end end end |
.render(format, *args, &block) ⇒ Object
18 19 20 |
# File 'lib/card/bootstrap/old_component.rb', line 18 def render format, *args, &block new(format, *args, &block).render end |
Instance Method Details
#render ⇒ Object
63 64 65 66 67 68 |
# File 'lib/card/bootstrap/old_component.rb', line 63 def render @rendered = begin render_content @content[-1] end end |