Module: MarkMapper::Plugins::PartialUpdates

Extended by:
ActiveSupport::Concern
Included in:
Document
Defined in:
lib/mark_mapper/plugins/partial_updates.rb

Defined Under Namespace

Classes: PartialUpdatesDisabledError

Instance Method Summary collapse

Instance Method Details

#fields_for_partial_updateObject


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/mark_mapper/plugins/partial_updates.rb', line 21

def fields_for_partial_update
  raise PartialUpdatesDisabledError if !partial_updates

  Hash.new.tap do |hash|
    attrs = _dealiased_attributes

    hash[:set_fields] = Array.new.tap do |array|
      attrs.each do |key, value|
        if !@_last_saved_attributes.include?(key) ||
            @_last_saved_attributes[key] != value
          array << key
        end
      end
    end

    hash[:unset_fields] = @_last_saved_attributes.keys - attrs.keys
  end
end

#initializeObject


16
17
18
19
# File 'lib/mark_mapper/plugins/partial_updates.rb', line 16

def initialize(*)
  _reset_partial_updates_callback
  super
end