Class: Bunster::ERBJacket

Inherits:
Object
  • Object
show all
Defined in:
lib/bunster/erb_jacket.rb

Overview

This makes it a tad simpler to create a clean ERB binding context. It works like so:

ERBJacket.wrap “A Foo is: <%= @foo -%>”, :foo => ‘not a bar’

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ ERBJacket

:nodoc:



11
12
13
# File 'lib/bunster/erb_jacket.rb', line 11

def initialize(hash) # :nodoc:
  hash.each { |k, v| instance_variable_set('@' + k.to_s, v) }
end

Class Method Details

.wrap(erb_template = '', instance_variables = {}) ⇒ Object

:nodoc:



19
20
21
# File 'lib/bunster/erb_jacket.rb', line 19

def self.wrap(erb_template = '', instance_variables = {}) # :nodoc:
  new(instance_variables).wrap erb_template
end

Instance Method Details

#wrap(erb_template) ⇒ Object

:nodoc:



15
16
17
# File 'lib/bunster/erb_jacket.rb', line 15

def wrap(erb_template) # :nodoc:
  ::ERB.new(erb_template, nil, '-').result binding
end