Sha256: f39fea07046c3762bf93cc4d3c187f41d3959e64d8838f45973328509482dc5e

Contents?: true

Size: 889 Bytes

Versions: 22

Compression:

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

22 entries across 22 versions & 1 rubygems

Version Path
quandl_client-2.10.0 lib/quandl/client/base/model.rb
quandl_client-2.9.0 lib/quandl/client/base/model.rb
quandl_client-2.8.0 lib/quandl/client/base/model.rb
quandl_client-2.7.12 lib/quandl/client/base/model.rb
quandl_client-2.7.9 lib/quandl/client/base/model.rb
quandl_client-2.7.8 lib/quandl/client/base/model.rb
quandl_client-2.7.7 lib/quandl/client/base/model.rb
quandl_client-2.7.6 lib/quandl/client/base/model.rb
quandl_client-2.7.3 lib/quandl/client/base/model.rb
quandl_client-2.7.2 lib/quandl/client/base/model.rb
quandl_client-2.7.1 lib/quandl/client/base/model.rb
quandl_client-2.7.0 lib/quandl/client/base/model.rb
quandl_client-2.6.2 lib/quandl/client/base/model.rb
quandl_client-2.6.1 lib/quandl/client/base/model.rb
quandl_client-2.6.0 lib/quandl/client/base/model.rb
quandl_client-2.5.3 lib/quandl/client/base/model.rb
quandl_client-2.5.2 lib/quandl/client/base/model.rb
quandl_client-2.5.1 lib/quandl/client/base/model.rb
quandl_client-2.5.0 lib/quandl/client/base/model.rb
quandl_client-2.4.9 lib/quandl/client/base/model.rb