Module: Paymill::Restful::Update

Included in:
Client, Offer, Subscription, Transaction, Webhook
Defined in:
lib/paymill/restful/methods.rb

Instance Method Summary collapse

Instance Method Details

#update(arguments = {}) ⇒ Object



47
48
49
50
51
52
53
# File 'lib/paymill/restful/methods.rb', line 47

def update( arguments = {} )
  arguments.merge! public_methods( false ).grep( /.*=/ ).map{ |m| m = m.id2name.chop; { m => send( m ) } }.reduce( :merge )

  response = Paymill.request( Http.put( Restful.demodulize_and_tableize( self.class.name ), self.id, Restful.normalize( arguments ) ) )
  source = self.class.new( response['data'] )
  self.instance_variables.each { |key| self.instance_variable_set( key, source.instance_variable_get( key ) ) }
end