main
1# frozen_string_literal: true
2
3module Scim
4 module Kit
5 # Represents a Jbuilder template
6 class Template
7 TEMPLATES_DIR = Pathname.new(File.join(__dir__, 'v2/templates/'))
8
9 attr_reader :target
10
11 def initialize(target)
12 @target = target
13 end
14
15 def to_json(options = {})
16 template.render(target, options)
17 end
18
19 private
20
21 def template_path
22 TEMPLATES_DIR.join(target.template_name)
23 end
24
25 def template
26 @template ||= Tilt.new(template_path.to_s)
27 end
28 end
29 end
30end