Class: Clerq::Services::RenderNode
- Defined in:
- lib/clerq/services/render_node.rb
Instance Method Summary collapse
- #call ⇒ Object
- #check_string_argument!(arg, str) ⇒ Object
- #check_string_empty!(arg, str) ⇒ Object
-
#initialize(node:, template:) ⇒ RenderNode
constructor
A new instance of RenderNode.
Methods inherited from Service
Constructor Details
#initialize(node:, template:) ⇒ RenderNode
Returns a new instance of RenderNode.
16 17 18 19 20 21 |
# File 'lib/clerq/services/render_node.rb', line 16 def initialize(node: , template:) check_string_argument!(template, 'template') check_string_empty!(template, 'template') @node = node @ett = template end |
Instance Method Details
#call ⇒ Object
11 12 13 14 |
# File 'lib/clerq/services/render_node.rb', line 11 def call @erb = QueryTemplate.(@ett) RenderErb.(erb: @erb, object: @node) end |
#check_string_argument!(arg, str) ⇒ Object
23 24 25 26 27 |
# File 'lib/clerq/services/render_node.rb', line 23 def check_string_argument!(arg, str) return if arg.is_a? String errmsg = ":#{str} must be String!" raise ArgumentError, errmsg, caller end |
#check_string_empty!(arg, str) ⇒ Object
29 30 31 32 33 |
# File 'lib/clerq/services/render_node.rb', line 29 def check_string_empty!(arg, str) return unless arg.empty? errmsg = ":#{str} cannot be empty!" raise ArgumentError, errmsg, caller end |