Class: EasyPost::Models::Object
- Inherits:
 - 
      Object
      
        
- Object
 - EasyPost::Models::Object
 
 
- Defined in:
 - lib/easypost/models/base.rb
 
Overview
The base class for all JSON objects in the library.
Direct Known Subclasses
Instance Method Summary collapse
- 
  
    
      #[](key)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Get element of an array.
 - 
  
    
      #[]=(key, value)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Set the element of an array.
 - 
  
    
      #initialize(data)  ⇒ Object 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of Object.
 - 
  
    
      #to_hash  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Convert object to hash.
 - 
  
    
      #to_s(*_args)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Convert to a string.
 
Constructor Details
#initialize(data) ⇒ Object
Returns a new instance of Object.
      7 8 9 10  | 
    
      # File 'lib/easypost/models/base.rb', line 7 def initialize(data) @values = data add_properties(data) end  | 
  
Instance Method Details
#[](key) ⇒ Object
Get element of an array.
      23 24 25  | 
    
      # File 'lib/easypost/models/base.rb', line 23 def [](key) @values[key.to_s] end  | 
  
#[]=(key, value) ⇒ Object
Set the element of an array.
      28 29 30  | 
    
      # File 'lib/easypost/models/base.rb', line 28 def []=(key, value) send(:"#{key}=", value) end  | 
  
#to_hash ⇒ Object
Convert object to hash
      18 19 20  | 
    
      # File 'lib/easypost/models/base.rb', line 18 def to_hash JSON.parse(JSON.dump(@values)) end  | 
  
#to_s(*_args) ⇒ Object
Convert to a string.
      13 14 15  | 
    
      # File 'lib/easypost/models/base.rb', line 13 def to_s(*_args) JSON.dump(@values) end  |