Sha256: 5fc5fbeaaa496c32687bd45ac8f75251b29519e6639c5373ba284ab1a6c2ca6e
Contents?: true
Size: 931 Bytes
Versions: 1
Compression:
Stored size: 931 Bytes
Contents
module SantanderChile module ApiClient module Template class ERBContext def initialize(hash) hash.each_pair do |key, value| instance_variable_set("@" + key.to_s, value) end end def get_binding binding end end path_templates = File.dirname(__FILE__) TEMPLATES = {} ["requests"].each do |category| Dir.foreach(path_templates + "/#{category}/") do |filename| next if !filename.include? "_template.json.erb" filename.slice! "_template.json.erb" TEMPLATES["#{category}/#{filename}"] = "#{path_templates}/#{category}/#{filename}_template.json.erb" end end def with_template(path, **objs) template_file = File.read(TEMPLATES[path]) context = ERBContext.new(objs) ERB.new(template_file).result(context.get_binding) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
santander_chile-api_client-1.1.1 | lib/santander_chile/api_client/templates/templates.rb |