class JSONFactory::TemplateStore
Public Class Methods
new()
click to toggle source
# File lib/json_factory/template_store.rb, line 7 def initialize @templates = {} end
Public Instance Methods
clear()
click to toggle source
# File lib/json_factory/template_store.rb, line 19 def clear @templates.clear end
get(path)
click to toggle source
# File lib/json_factory/template_store.rb, line 11 def get(path) if @templates.key? path @templates.fetch(path) else @templates.store(path, read_template(path)) end end
Private Instance Methods
read_template(path)
click to toggle source
# File lib/json_factory/template_store.rb, line 25 def read_template(path) raise "file format is invalid. #{path}" unless File.extname(path).eql?('.jfactory') raise "jfactory file #{path} not found" unless File.exist?(path) File.read(path) end