Sha256: 026f0edca85c2213b982beb6e37d73bf662eb4a3204fa2c9cc4d0da839d00f6f

Contents?: true

Size: 890 Bytes

Versions: 8

Compression:

Stored size: 890 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

8 entries across 8 versions & 1 rubygems

Version Path
quandl_client-2.4.6 lib/quandl/client/base/model.rb
quandl_client-2.4.5 lib/quandl/client/base/model.rb
quandl_client-2.4.4 lib/quandl/client/base/model.rb
quandl_client-2.4.3 lib/quandl/client/base/model.rb
quandl_client-2.4.2 lib/quandl/client/base/model.rb
quandl_client-2.4.1 lib/quandl/client/base/model.rb
quandl_client-2.4.0 lib/quandl/client/base/model.rb
quandl_client-2.3.2 lib/quandl/client/base/model.rb