Class: Props::Template
- Inherits:
-
Object
- Object
- Props::Template
- Defined in:
- lib/props_template.rb
Class Attribute Summary collapse
-
.template_lookup_options ⇒ Object
Returns the value of attribute template_lookup_options.
Instance Method Summary collapse
- #builder! ⇒ Object
-
#initialize(context = nil, options = {}) ⇒ Template
constructor
A new instance of Template.
- #set!(key, options = {}, &block) ⇒ Object (also: #method_missing)
Constructor Details
#initialize(context = nil, options = {}) ⇒ Template
Returns a new instance of Template.
22 23 24 25 |
# File 'lib/props_template.rb', line 22 def initialize(context = nil, = {}) @builder = BaseWithExtensions.new(self, context, ) @context = context end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing ⇒ Object (private)
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/props_template.rb', line 49 def set!(key, = {}, &block) if block_given? && [:search] && !@builder.is_a?(Searcher) prev_builder = @builder @builder = Searcher.new(self, [:search], @context) .delete(:search) @builder.set!(key, , &block) found_block, = @builder.found! @builder = prev_builder if found_block set!(key, , &found_block) end else @builder.set!(key, , &block) end end |
Class Attribute Details
.template_lookup_options ⇒ Object
Returns the value of attribute template_lookup_options.
10 11 12 |
# File 'lib/props_template.rb', line 10 def @template_lookup_options end |
Instance Method Details
#builder! ⇒ Object
45 46 47 |
# File 'lib/props_template.rb', line 45 def builder! @builder end |
#set!(key, options = {}, &block) ⇒ Object Also known as: method_missing
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/props_template.rb', line 27 def set!(key, = {}, &block) if block_given? && [:search] && !@builder.is_a?(Searcher) prev_builder = @builder @builder = Searcher.new(self, [:search], @context) .delete(:search) @builder.set!(key, , &block) found_block, = @builder.found! @builder = prev_builder if found_block set!(key, , &found_block) end else @builder.set!(key, , &block) end end |