Sha256: 6424a65557d4b8c0854d81827d565df9f64ac8c4aab1eb1a5ff1cfc2d0d8736a
Contents?: true
Size: 853 Bytes
Versions: 3
Compression:
Stored size: 853 Bytes
Contents
class Polly::Context < BasicObject include ::Polly::Common include ::Kernel def initialize(env) @env = env @env.clean.each { |name, expr| var_reader name.to_sym } end def evaluate(proc) instance_eval(&proc) if proc end def var(name, val = nil, opts = {}) if @env[name] @env[name].replace(val) else @env[name] = Sexpr.build(val, @env, name) end var_reader name end def Sexpr(val) Polly::Sexpr.build(val, @env) end alias_method :const, :var alias_method :eq, :var # magix # convert method calls on self to s-expressions # def method_missing(method, *args, &block) Sexpr.build([method, *args], @env) end def self.const_missing(name) ::Object.const_get(name) end private def var_reader(name) define_singleton_method(name) { @env[name] } end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
polly-0.0.6 | lib/polly/context.rb |
polly-0.0.5 | lib/polly/context.rb |
polly-0.0.4 | lib/polly/context.rb |