Class: Datacentred::Model::Base

Inherits:
RecursiveOpenStruct
  • Object
show all
Defined in:
lib/datacentred/model/base.rb

Overview

Base class for all API models.

Uses Recursive Structs to allow nested property access.

Direct Known Subclasses

Project, Role, Usage, User, Version

Instance Method Summary collapse

Constructor Details

#initialize(params, _opts = nil) ⇒ Base

Instantiate a new model object.

Parameters:

  • params (Hash)

    Object properties as returned by the API.



10
11
12
13
14
15
16
17
18
# File 'lib/datacentred/model/base.rb', line 10

def initialize(params, _opts=nil)
  params.delete "links" if params['links']
  
  ["created_at", "updated_at", "last_updated_at"].each do |key|
    params[key] = Time.parse(params[key]) if params[key]
  end

  super params, recurse_over_arrays: true
end