Sha256: 7c43026c75982b746ad0b20f07d982433bfc948badf11f3e157b5c0ef01fea63

Contents?: true

Size: 664 Bytes

Versions: 4

Compression:

Stored size: 664 Bytes

Contents

module DataMapper
  module Resource
    def adjust(attributes = {}, reload = false)
      raise NotImplementedError, 'adjust *with* validations has not be written yet, try adjust!'
    end

    def adjust!(attributes = {}, reload = false)
      return true if attributes.empty?

      adjust_attributes = {}

      model.properties(repository.name).slice(*attributes.keys).each do |property|
        adjust_attributes[property] = attributes[property.name] if property
      end

      repository.adapter.adjust(adjust_attributes, to_query)

      collection.reload(:fields => adjust_attributes.keys) if reload

      true
    end
  end # Resource
end # DataMapper

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dm-adjust-0.9.10 lib/dm-adjust/resource.rb
dm-adjust-0.9.11 lib/dm-adjust/resource.rb
dm-adjust-0.9.8 lib/dm-adjust/resource.rb
dm-adjust-0.9.9 lib/dm-adjust/resource.rb