Class: ApRubySdk::BaseModel

Inherits:
Object
  • Object
show all
Defined in:
lib/ap_ruby_sdk/base_model.rb

Direct Known Subclasses

ApiResource, Pagination, Payment, RedirectUrls

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ BaseModel

Returns a new instance of BaseModel.



8
9
10
# File 'lib/ap_ruby_sdk/base_model.rb', line 8

def initialize(attributes={})
  self.attributes = attributes
end

Instance Attribute Details

#createdObject

Returns the value of attribute created.



3
4
5
# File 'lib/ap_ruby_sdk/base_model.rb', line 3

def created
  @created
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/ap_ruby_sdk/base_model.rb', line 3

def id
  @id
end

#modeObject

Returns the value of attribute mode.



3
4
5
# File 'lib/ap_ruby_sdk/base_model.rb', line 3

def mode
  @mode
end

#updatedObject

Returns the value of attribute updated.



3
4
5
# File 'lib/ap_ruby_sdk/base_model.rb', line 3

def updated
  @updated
end

Instance Method Details

#attributes=(attributes) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/ap_ruby_sdk/base_model.rb', line 12

def attributes=(attributes)
  if attributes.respond_to?(:each)
    attributes.each do |key, value|
      writer = (key == 'type' ? 'kind=' : "#{key}=")
      if respond_to?(writer)
        send(writer, value)
      end
    end
  else
    attributes
  end
end

#to_jsonObject



25
26
27
28
29
# File 'lib/ap_ruby_sdk/base_model.rb', line 25

def to_json
  hash = {}
  instance_variables.each { |var| hash[var.to_s.delete("@")] = instance_variable_get(var) }
  hash.to_json
end