Class: SimpleJson::SimpleJsonTemplate

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_json/simple_json_template.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ SimpleJsonTemplate

Returns a new instance of SimpleJsonTemplate.



5
6
7
8
# File 'lib/simple_json/simple_json_template.rb', line 5

def initialize(path)
  @path = path
  @source = File.read(path)
end

Instance Method Details

#codeObject



14
15
16
# File 'lib/simple_json/simple_json_template.rb', line 14

def code
  @code ||= lambda_stringify(@source)
end

#rendererObject



10
11
12
# File 'lib/simple_json/simple_json_template.rb', line 10

def renderer
  @renderer ||= eval(code, TOPLEVEL_BINDING, @path) # rubocop:disable Security/Eval
end