Class: Bemer::Template
- Inherits:
-
CommonTemplate
- Object
- CommonTemplate
- Bemer::Template
- Extended by:
- Forwardable
- Defined in:
- lib/bemer/template.rb
Instance Attribute Summary
Attributes inherited from CommonTemplate
Instance Method Summary collapse
- #apply(node) ⇒ Object
- #apply!(node) ⇒ Object
-
#initialize(mode, body, predicate) ⇒ Template
constructor
A new instance of Template.
Constructor Details
#initialize(mode, body, predicate) ⇒ Template
Returns a new instance of Template.
11 12 13 14 15 16 17 18 |
# File 'lib/bemer/template.rb', line 11 def initialize(mode, body, predicate) super(mode) @add_mode = !@mode.eql?(mode) @body = body @method = [@mode, '='].join.to_sym @predicate = predicate end |
Instance Method Details
#apply(node) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/bemer/template.rb', line 20 def apply(node) case mode when Pipeline::REPLACE_MODE then replace(node) when Pipeline::CONTENT_MODE then capture_content(node) else node.entity_builder.public_send(method, capture_body(node), false) end end |
#apply!(node) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/bemer/template.rb', line 28 def apply!(node) return replace!(node) if Pipeline::REPLACE_MODE.eql?(mode) content = Pipeline::CONTENT_MODE.eql?(mode) ? capture_content!(node) : capture_body(node) node.entity_builder.public_send(method, content) end |