Sha256: f4cfdbf3ee3a6563d024be57f38016e8da88a6f892e7c2d883c02c0d9225b03e

Contents?: true

Size: 860 Bytes

Versions: 3

Compression:

Stored size: 860 Bytes

Contents

module Paymill
  module Operations
    module Update

      module ClassMethods
        # Updates a object
        # @param [Integer] id The id of the object that should be updated
        # @param [Hash] attributes The attributes that should be updated
        def update_attributes(id, attributes)
          response = Paymill.request(:put, "#{self.name.split("::").last.downcase}s/#{id}", attributes)
          self.new(response["data"])
        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(attributes)
        response = Paymill.request(:put, "#{self.class.name.split("::").last.downcase}s/#{id}", attributes)
        set_attributes(response["data"])
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
paymill-0.5.1 lib/paymill/operations/update.rb
paymill-0.5.0 lib/paymill/operations/update.rb
paymill-0.4.0 lib/paymill/operations/update.rb