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

Version Path
backlog-0.0.0 vendor/rails/activeresource/test/setter_trap.rb
backlog-0.0.1 vendor/rails/activeresource/test/setter_trap.rb
backlog-0.0.2 vendor/rails/activeresource/test/setter_trap.rb
backlog-0.0.5 vendor/rails/activeresource/test/setter_trap.rb
backlog-0.0.4 vendor/rails/activeresource/test/setter_trap.rb
backlog-0.1.1 vendor/rails/activeresource/test/setter_trap.rb
backlog-0.1.0 vendor/rails/activeresource/test/setter_trap.rb
backlog-0.1.2 vendor/rails/activeresource/test/setter_trap.rb
backlog-0.2.0 vendor/rails/activeresource/test/setter_trap.rb
backlog-0.2.1 vendor/rails/activeresource/test/setter_trap.rb
backlog-0.3.0 vendor/rails/activeresource/test/setter_trap.rb
backlog-0.3.3 vendor/rails/activeresource/test/setter_trap.rb
backlog-0.3.2 vendor/rails/activeresource/test/setter_trap.rb
backlog-0.3.1 vendor/rails/activeresource/test/setter_trap.rb
backlog-0.3.4 vendor/rails/activeresource/test/setter_trap.rb
backlog-0.3.5 vendor/rails/activeresource/test/setter_trap.rb
backlog-0.3.6 vendor/rails/activeresource/test/setter_trap.rb
backlog-0.3.8 vendor/rails/activeresource/test/setter_trap.rb
backlog-0.3.7 vendor/rails/activeresource/test/setter_trap.rb
backlog-0.3.9 vendor/rails/activeresource/test/setter_trap.rb