Sha256: af34213a51cf600cb87106dd3171972061f7e2f74fd539fe3eb3c3d492fb7ba2

Contents?: true

Size: 911 Bytes

Versions: 3

Compression:

Stored size: 911 Bytes

Contents

class Quandl::Client::Base
  module Model

    extend ActiveSupport::Concern

    included do

      include Her::Model
      use_api Quandl::Client::Base.her_api

      before_save :touch_request_started_at
      after_save :touch_request_finished_at

      before_destroy :touch_request_started_at
      after_destroy :touch_request_finished_at

      attr_accessor :request_started_at, :request_finished_at

    end

    def elapsed_request_time_ms
      elapsed_request_time.to_f.microseconds.to_s + 'ms'
    end

    def elapsed_request_time
      return nil unless request_finished_at.is_a?(Time) && request_started_at.is_a?(Time)
      @elapsed_request_time ||= (request_finished_at - request_started_at)
    end

    private

    def touch_request_started_at
      self.request_started_at = Time.now
    end

    def touch_request_finished_at
      self.request_finished_at = Time.now
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
quandl_client-2.13.0 lib/quandl/client/base/model.rb
quandl_client-2.12.0 lib/quandl/client/base/model.rb
quandl_client-2.11.0 lib/quandl/client/base/model.rb