Sha256: 34e412cf15b4626be53576114351d7c86440a78e9871225f84f766b16a2f7a7b

Contents?: true

Size: 607 Bytes

Versions: 2

Compression:

Stored size: 607 Bytes

Contents

module NCore
  module Update
    extend ActiveSupport::Concern

    module ClassMethods
      def update!(id, attribs, api_creds=nil)
        obj = new({id: id}, api_creds)
        obj.save!(attribs)
      end

      def update(id, attribs, api_creds=nil)
        obj = new({id: id}, api_creds)
        obj.save(attribs)
      end
    end


    private

    def update(attribs={})
      params = {json_root => attribs}
      parsed, @api_creds = request(:put, url, api_creds, params)
      load(data: attribs) if parsed[:errors].any?
      load(parsed)
      errors.empty? ? self : false
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ncore-1.1.0 lib/ncore/methods/update.rb
ncore-1.0.0 lib/ncore/methods/update.rb