Sha256: 572dea5943f9f57f72c1ab3b62936afd1cac20513c8288f20c8e6f640be90012

Contents?: true

Size: 615 Bytes

Versions: 1

Compression:

Stored size: 615 Bytes

Contents

module Datacentred
  module Model
    # Base class for all API models.
    #
    # Uses Recursive Structs to allow nested property access.
    class Base < RecursiveOpenStruct
      # Instantiate a new model object.
      #
      # @param [Hash] params Object properties as returned by the API.
      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
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
datacentred-1.1.1 lib/datacentred/model/base.rb