Sha256: 6c617e7827a20cb4157c77443a8a4657ff7416a5d141b0180b613788db9da7b4
Contents?: true
Size: 548 Bytes
Versions: 56
Compression:
Stored size: 548 Bytes
Contents
require 'builder' class SetterTrap < Builder::BlankSlate class << self def rollback_sets(obj) returning yield(setter_trap = new(obj)) do setter_trap.rollback_sets end end end def initialize(obj) @cache = {} @obj = obj end def respond_to?(method) @obj.respond_to?(method) end def method_missing(method, *args, &proc) @cache[method] ||= @obj.send($`) if method.to_s =~ /=$/ @obj.send method, *args, &proc end def rollback_sets @cache.each { |k, v| @obj.send k, v } end end
Version data entries
56 entries across 56 versions & 1 rubygems