Class: Mab::SimpleBuilder
Direct Known Subclasses
Instance Method Summary collapse
- #capture(&blk) ⇒ Object
-
#initialize(assigns = {}, helper = nil, &blk) ⇒ SimpleBuilder
constructor
A new instance of SimpleBuilder.
- #method_missing(name, *args, &blk) ⇒ Object
- #to_s ⇒ Object
Methods included from Mixin
#mab, #mab_done, #mab_insert, #mab_options, #mab_tag, #tag!, #text, #text!
Constructor Details
#initialize(assigns = {}, helper = nil, &blk) ⇒ SimpleBuilder
Returns a new instance of SimpleBuilder.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/mab/builder.rb', line 5 def initialize(assigns = {}, helper = nil, &blk) @_helper = helper @_result = [] assigns.each do |key, value| instance_variable_set(:"@#{key}", value) end if helper helper.instance_variables.each do |var| instance_variable_set(var, helper.instance_variable_get(var)) end end capture(&blk) if blk end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &blk) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/mab/builder.rb', line 28 def method_missing(name, *args, &blk) if @_helper && @_helper.respond_to?(name, true) @_helper.send(name, *args, &blk) else super end end |
Instance Method Details
#capture(&blk) ⇒ Object
22 23 24 |
# File 'lib/mab/builder.rb', line 22 def capture(&blk) @_result << mab(&blk) end |
#to_s ⇒ Object
26 |
# File 'lib/mab/builder.rb', line 26 def to_s; @_result.join end |