class Orbit::TemplateBinding

Public Class Methods

locals(hash) click to toggle source
# File lib/orbit/template_binding.rb, line 11
def self.locals(hash)
  new(hash).locals
end
new(hash) click to toggle source
# File lib/orbit/template_binding.rb, line 3
def initialize(hash)
  @variables = {}

  hash.each do |key, value|
    @variables[key.to_sym] = value
  end
end

Public Instance Methods

locals() click to toggle source
# File lib/orbit/template_binding.rb, line 15
def locals
  @variables
end
method_missing(method, *args, &block) click to toggle source
# File lib/orbit/template_binding.rb, line 27
def method_missing(method, *args, &block)
  if method.to_s[-1] == '='
    var_name = method.to_s[0..-2].to_sym
    @variables[var_name] = args.first
  end
end
variables() click to toggle source
# File lib/orbit/template_binding.rb, line 19
def variables
  binding.tap do |bind|
    @variables.each do |key, value|
      bind.local_variable_set(key.to_sym, value)
    end
  end
end