Sha256: 1fe56dd7d4fada732d201609c71a3171e03482e2235807075cdf0c333e164daa
Contents?: true
Size: 1.05 KB
Versions: 12
Compression:
Stored size: 1.05 KB
Contents
require 'set' module Datacaster module Runtimes class ObjectContext < Base def initialize(parent, object) super(parent) @object = object @reserved_instance_variables += instance_variables end def method_missing(m, *args, &block) if @object.respond_to?(m) @object.public_send(m, *args, &block) else super end end def respond_to_missing?(m, include_private = false) @object.respond_to?(m, include_private) || super end def after_call!(sender) (sender.instance_variables.to_set - sender.reserved_instance_variables).each do |k| @object.instance_variable_set(k, sender.instance_variable_get(k)) sender.remove_instance_variable(k) end super end def before_call!(sender) super (@object.instance_variables.to_set - sender.reserved_instance_variables).each do |k| sender.instance_variable_set(k, @object.instance_variable_get(k)) end end end end end
Version data entries
12 entries across 12 versions & 1 rubygems