Class: Grease::Adapter
- Inherits:
-
Object
- Object
- Grease::Adapter
- Defined in:
- lib/grease/adapter.rb
Instance Method Summary collapse
- #call(input) ⇒ Object
-
#initialize(template_class) ⇒ Adapter
constructor
A new instance of Adapter.
- #inspect ⇒ Object
Constructor Details
#initialize(template_class) ⇒ Adapter
Returns a new instance of Adapter.
3 4 5 |
# File 'lib/grease/adapter.rb', line 3 def initialize(template_class) @template_class = template_class end |
Instance Method Details
#call(input) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/grease/adapter.rb', line 7 def call(input) context = input[:environment].context_class.new(input) template = @template_class.new { input[:data] } # TODO: Hack for converting ActiveSupport::SafeBuffer into String data = template.render(context, {}).to_str context..merge(data: data) end |
#inspect ⇒ Object
16 17 18 |
# File 'lib/grease/adapter.rb', line 16 def inspect "#<#{self.class.name}(#{@template_class.name}):#{format('%#016x', object_id << 1)}>" end |