Sha256: fa06011a3fcf99245c549cf59c77025659489f3c4c851cbf84b5615f5a28c423
Contents?: true
Size: 535 Bytes
Versions: 2
Compression:
Stored size: 535 Bytes
Contents
# frozen_string_literal: true class SetterTrap < BasicObject class << self def rollback_sets(obj) trapped = new(obj) yield(trapped).tap { trapped.rollback_sets } 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
active_cached_resource-0.1.0 | lib/activeresource/test/setter_trap.rb |
active_cached_resource-0.0.1.pre | lib/activeresource/test/setter_trap.rb |