Sha256: 85082ba8b2b0b71b75c449cc355bbfcf4975327d06110b7f76f56aac71d5ce4a
Contents?: true
Size: 716 Bytes
Versions: 3
Compression:
Stored size: 716 Bytes
Contents
# encoding: utf-8 # frozen_string_literal: true module Brandish # Executes a string of code in the instance of the class. # # @api private class Execute # Initialize the execution context. # # @param context [{::Symbol, ::String => ::Object}] The context. The keys # are set as instance variables on the class, with the values being the # instance variable's respective value. def initialize(context) context.each { |k, v| instance_variable_set(:"@#{k}", v) } end # Executes the given code in the context of the class. # # @param code [::String] The code to execute. # @return [::Object] def exec(code) instance_exec(code) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
brandish-0.1.3 | lib/brandish/execute.rb |
brandish-0.1.2 | lib/brandish/execute.rb |
brandish-0.1.1 | lib/brandish/execute.rb |