Sha256: 8023d32534cbaca5800aa61cabeafdd2418aa7d55499650a194a9c3ce5d73fac

Contents?: true

Size: 998 Bytes

Versions: 17

Compression:

Stored size: 998 Bytes

Contents

# encoding: utf-8

I18n.load_path << File.join(
  File.dirname(__FILE__), "validations", "locale", "en.yml"
)

module CouchRest
  module Model

    # This applies to both Model::Base and Model::CastedModel
    module Dirty
      extend ActiveSupport::Concern
      include ActiveModel::Dirty

      included do
        # internal dirty setting - overrides global setting.
        # this is used to temporarily disable dirty tracking when setting 
        # attributes directly, for performance reasons.
        self.send(:attr_accessor, :disable_dirty)
      end

      def use_dirty?
        doc = base_doc
        doc && !doc.disable_dirty
      end

      def couchrest_attribute_will_change!(attr)
        return if attr.nil? || !use_dirty?
        attribute_will_change!(attr)
        couchrest_parent_will_change!
      end

      def couchrest_parent_will_change!
        casted_by.couchrest_attribute_will_change!(casted_by_property.name) if casted_by_property
      end

    end
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
couchrest_model-2.1.0.rc1 lib/couchrest/model/dirty.rb
couchrest_model-2.1.0.beta2 lib/couchrest/model/dirty.rb
couchrest_model-2.1.0.beta1 lib/couchrest/model/dirty.rb
couchrest_model-2.0.4 lib/couchrest/model/dirty.rb
couchrest_model-2.0.3 lib/couchrest/model/dirty.rb
couchrest_model-2.0.1 lib/couchrest/model/dirty.rb
couchrest_model-2.0.0 lib/couchrest/model/dirty.rb
couchrest_model-2.0.0.beta2 lib/couchrest/model/dirty.rb
couchrest_model-2.0.0.beta lib/couchrest/model/dirty.rb
couchrest_model-1.2.0.beta lib/couchrest/model/dirty.rb
openlogic-couchrest_model-1.0.0 lib/couchrest/model/dirty.rb
couchrest_model-1.1.2 lib/couchrest/model/dirty.rb
couchrest_model-1.1.1 lib/couchrest/model/dirty.rb
couchrest_model-1.1.0 lib/couchrest/model/dirty.rb
couchrest_model-1.1.0.rc1 lib/couchrest/model/dirty.rb
couchrest_model-1.1.0.beta5 lib/couchrest/model/dirty.rb
couchrest_model-1.1.0.beta4 lib/couchrest/model/dirty.rb