Sha256: 24d3d62e080539ad5b72407145c426657f378d2a154ced10e96a91b621a616ac

Contents?: true

Size: 811 Bytes

Versions: 1

Compression:

Stored size: 811 Bytes

Contents

require "undo"
require_relative "wrapper/configuration"
require_relative "wrapper_integration"
require "forwardable"

module Undo
  class Wrapper < SimpleDelegator
    def self.configure
      yield config
    end

    def self.config
      @config ||= Configuration.new
    end

    extend Forwardable
    def_delegators :object, :class, :kind_of?

    attr_reader :undo_uuid, :config

    def initialize(object, options)
      @object = object
      @config = Undo::Wrapper.config.with options
      @options = options

      super object
    end

    def method_missing(method, *args, &block)
      store if config.store_on.include? method
      super method, *args, &block
    end

    private
    attr_reader :object, :options

    def store
      @undo_uuid = Undo.store object, options
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
undo-wrapper-0.0.1 lib/undo/wrapper.rb