class Grease::Adapter

Public Class Methods

new(template_class) click to toggle source
# File lib/grease/adapter.rb, line 3
def initialize(template_class)
  @template_class = template_class
end

Public Instance Methods

call(input) click to toggle source
# File lib/grease/adapter.rb, line 7
def call(input)
  context = input[:environment].context_class.new(input)
  template = @template_class.new { input[:data] }

  # NOTE: Call #to_str to convert ActiveSupport::SafeBuffer into String
  context.metadata.merge(data: template.render(context).to_str)
end
inspect() click to toggle source
# File lib/grease/adapter.rb, line 15
def inspect
  "#<#{self.class.name}(#{@template_class.name}):#{format('%#016x', object_id << 1)}>"
end