Sha256: ae6fa96a6cecb421518a69b829cf596d2b4ed9032106ceb564a9a29a298003a1
Contents?: true
Size: 763 Bytes
Versions: 2
Compression:
Stored size: 763 Bytes
Contents
require "forwardable" module Undo class Model < SimpleDelegator extend Forwardable def_delegators :object, :class, :kind_of? def initialize(object, options = {}) @object = object @config = config.with options super object end def uuid @uuid ||= object.respond_to?(:uuid) ? object.uuid : generate_uuid end def method_missing(method, *args, &block) store if config.mutator_methods.include? method super method, *args, &block end private attr_reader :object def generate_uuid config.uuid_generator.call object end def store config.storage.put uuid, config.serializer.serialize(object) end def config @config ||= Undo.config end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
undo-0.0.3 | lib/undo/model.rb |
undo-0.0.2 | lib/undo/model.rb |