Sha256: 127e690cd3b505e6007aef56fb02b146f6789680520fd85ab984e83f82c77016

Contents?: true

Size: 827 Bytes

Versions: 3

Compression:

Stored size: 827 Bytes

Contents

module Shipcloud
  module Operations
    module Update

      module ClassMethods
        # Updates a object
        # @param [String] id The id of the object that should be updated
        # @param [Hash] attributes The attributes that should be updated
        def update(id, attributes)
          response = Shipcloud.request(:put, "#{self.name.split("::").last.downcase}s/#{id}", attributes)
          self.new(response)
        end
      end

      def self.included(base)
        base.extend(ClassMethods)
      end

      # Updates a object
      #
      # @param [Hash] attributes The attributes that should be updated
      def update(attributes)
        response = Shipcloud.request(:put, "#{self.class.name.split("::").last.downcase}s/#{id}", attributes)
        set_attributes(response)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
shipcloud-0.5.0 lib/shipcloud/operations/update.rb
shipcloud-0.4.0 lib/shipcloud/operations/update.rb
shipcloud-0.3.0 lib/shipcloud/operations/update.rb