Class: Easyrb::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/easyrb/runner.rb

Constant Summary collapse

VALID_OPTIONS =
[:context, :helpers, :locals]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(erb_template) ⇒ Runner

# Constructor #

#


24
25
26
# File 'lib/easyrb/runner.rb', line 24

def initialize(erb_template)
  @erb_template = erb_template
end

Instance Attribute Details

#erb_templateObject (readonly)

# Declarations #

#


14
15
16
# File 'lib/easyrb/runner.rb', line 14

def erb_template
  @erb_template
end

Instance Method Details

#run(options = {}) ⇒ Object

# Instance Methods #

#


34
35
36
37
38
39
40
41
# File 'lib/easyrb/runner.rb', line 34

def run(options = {})
  validate_options!(options)

  object  = Easyrb::Context[options[:context], options[:helpers]]
  binding = Easyrb::Local[object, options[:locals]]

  erb.result(binding)
end