Sha256: a2dc7d00f3e048a9072e6e9f3cc41aa882dc170356501d9c8f44e917fb268926

Contents?: true

Size: 536 Bytes

Versions: 17

Compression:

Stored size: 536 Bytes

Contents

class SetterTrap < ActiveSupport::BasicObject
  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

17 entries across 16 versions & 7 rubygems

Version Path
radiant-0.7.2 vendor/rails/activeresource/test/setter_trap.rb
vibes-bj-1.2.2 spec/rails_root/vendor/rails/activeresource/test/setter_trap.rb
vibes-bj-1.2.1 spec/rails_root/vendor/rails/activeresource/test/setter_trap.rb
usher-0.7.0 spec/rails2_2/vendor/rails/vendor/rails/activeresource/pkg/activeresource-2.2.2/test/setter_trap.rb
usher-0.7.0 spec/rails2_2/vendor/rails/vendor/rails/activeresource/test/setter_trap.rb
activeresource-2.2.3 test/setter_trap.rb
active_lastfm-1.0.0 test/setter_trap.rb
activeresource-2.1.1 test/setter_trap.rb
activeresource-2.2.2 test/setter_trap.rb
activeresource-2.3.0 test/setter_trap.rb
activeresource-2.1.2 test/setter_trap.rb
activeresource-2.1.0 test/setter_trap.rb
antfarm-0.3.0 rails/vendor/rails/activeresource/test/setter_trap.rb
antfarm-0.4.0 rails/vendor/rails/activeresource/test/setter_trap.rb
radiant-0.7.0 vendor/rails/activeresource/test/setter_trap.rb
radiant-0.7.1 vendor/rails/activeresource/test/setter_trap.rb
swivel-0.0.175 vendor/activeresource/test/setter_trap.rb