Sha256: d6524583c30fa3396865bf26d82cc8289a73f00d3e6fdd6606640fb069e9eeb4

Contents?: true

Size: 630 Bytes

Versions: 11

Compression:

Stored size: 630 Bytes

Contents

require 'bigdecimal'
module CouchPotato
  module Persistence
    module DirtyAttributes

      def self.included(base) #:nodoc:
        base.send :include, ActiveModel::Dirty
        base.class_eval do
          after_save :clear_changes_information
        end
      end

      def clone_attribute(value)
        if [Integer, Symbol, TrueClass, FalseClass, NilClass, Float, BigDecimal].find{|klass| value.is_a?(klass)}
          value
        elsif [Hash, Array].include?(value.class)
          #Deep clone
          Marshal::load(Marshal::dump(value))
        else
          value.clone
         end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
couch_potato-1.17.0 lib/couch_potato/persistence/dirty_attributes.rb
couch_potato-1.16.0 lib/couch_potato/persistence/dirty_attributes.rb
couch_potato-1.15.0 lib/couch_potato/persistence/dirty_attributes.rb
couch_potato-1.14.0 lib/couch_potato/persistence/dirty_attributes.rb
couch_potato-1.13.0 lib/couch_potato/persistence/dirty_attributes.rb
couch_potato-1.12.1 lib/couch_potato/persistence/dirty_attributes.rb
couch_potato-1.12.0 lib/couch_potato/persistence/dirty_attributes.rb
couch_potato-1.11.0 lib/couch_potato/persistence/dirty_attributes.rb
couch_potato-1.10.1 lib/couch_potato/persistence/dirty_attributes.rb
couch_potato-1.10.0 lib/couch_potato/persistence/dirty_attributes.rb
couch_potato-1.9.0 lib/couch_potato/persistence/dirty_attributes.rb