Class: WebPay::EventData

Inherits:
Entity
  • Object
show all
Defined in:
lib/webpay/data_types.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Entity

#normalize_hash, #to_h, #to_s

Constructor Details

#initialize(hash = {}) ⇒ EventData

Returns a new instance of EventData.



1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
# File 'lib/webpay/data_types.rb', line 1509

def initialize(hash = {})
  hash = normalize_hash(hash)
  hash['object'] =
  case hash['object'].is_a?(Hash) && hash['object']['object']
  when 'account'; AccountResponse.new(hash['object'])
  when 'charge'; ChargeResponse.new(hash['object'])
  when 'customer'; CustomerResponse.new(hash['object'])
  when 'recursion'; RecursionResponse.new(hash['object'])
  when 'shop'; ShopResponse.new(hash['object'])
  else; hash['object']
  end

  @attributes = hash
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



1502
1503
1504
# File 'lib/webpay/data_types.rb', line 1502

def attributes
  @attributes
end

Class Method Details

.fieldsObject



1504
1505
1506
# File 'lib/webpay/data_types.rb', line 1504

def self.fields
  ['object', 'previous_attributes']
end

Instance Method Details

#objectObject

attributes accessors



1527
1528
1529
# File 'lib/webpay/data_types.rb', line 1527

def object
  attributes['object']
end

#previous_attributesObject



1531
1532
1533
# File 'lib/webpay/data_types.rb', line 1531

def previous_attributes
  attributes['previous_attributes']
end