Class: Braai::Context
- Inherits:
-
Object
- Object
- Braai::Context
- Defined in:
- lib/braai/context.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#fallback ⇒ Object
Returns the value of attribute fallback.
-
#matchers ⇒ Object
Returns the value of attribute matchers.
-
#substrate ⇒ Object
Returns the value of attribute substrate.
Instance Method Summary collapse
-
#initialize(substrate, template, attributes = {}) ⇒ Context
constructor
A new instance of Context.
- #render ⇒ Object
Constructor Details
#initialize(substrate, template, attributes = {}) ⇒ Context
Returns a new instance of Context.
5 6 7 8 9 10 |
# File 'lib/braai/context.rb', line 5 def initialize(substrate, template, attributes = {}) self.attributes = HashWithIndifferentAccess.new(attributes) self.substrate = substrate.dup self.matchers = template.matchers self.fallback = template.fallback end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
3 4 5 |
# File 'lib/braai/context.rb', line 3 def attributes @attributes end |
#fallback ⇒ Object
Returns the value of attribute fallback.
3 4 5 |
# File 'lib/braai/context.rb', line 3 def fallback @fallback end |
#matchers ⇒ Object
Returns the value of attribute matchers.
3 4 5 |
# File 'lib/braai/context.rb', line 3 def matchers @matchers end |
#substrate ⇒ Object
Returns the value of attribute substrate.
3 4 5 |
# File 'lib/braai/context.rb', line 3 def substrate @substrate end |
Instance Method Details
#render ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/braai/context.rb', line 12 def render begin self.matchers.each do |regex, matcher| substitute(regex, matcher) end if self.fallback substitute(self.fallback[:regex], self.fallback[:handler]) end return self.substrate rescue Exception => e Braai.logger.error(e) raise e unless Braai.config.swallow_matcher_errors end end |