Sha256: 678c09fd0b2a7f1c57b3ea96d081b6f6999c661e027489e881b736e6f7fc0565

Contents?: true

Size: 936 Bytes

Versions: 23

Compression:

Stored size: 936 Bytes

Contents

module Rhoconnect  
  class ReadState < StoreOrm
    field :refresh_time, :integer
    field :prev_refresh_time, :integer
    field :retry_counter, :integer
  
    def self.create(fields)
      fields[:id] = get_id(fields)
      fields.delete(:app_id)
      fields.delete(:user_id)
      fields.delete(:source_name)
      fields[:refresh_time] ||= Time.now.to_i
      fields[:prev_refresh_time] ||= Time.now.to_i
      fields[:retry_counter] ||= 0
      super(fields,{})
    end
  
    def self.load(params)
      super(get_id(params),{})
    end
    
    def self.delete(app_id)
      Store.flush_data("#{class_prefix(self)}:#{app_id}:*")
    end
    
    def self.delete_user(params)
      Store.flush_data("#{class_prefix(self)}:#{params[:app_id]}:#{params[:user_id]}:#{params[:source_name]}:*")
    end

    private
    def self.get_id(params)
      "#{params[:app_id]}:#{params[:user_id]}:#{params[:source_name]}"
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
rhoconnect-7.6.0 lib/rhoconnect/read_state.rb
rhoconnect-7.5.1 lib/rhoconnect/read_state.rb
rhoconnect-7.4.1 lib/rhoconnect/read_state.rb
rhoconnect-7.1.17 lib/rhoconnect/read_state.rb
rhoconnect-6.2.0 lib/rhoconnect/read_state.rb
rhoconnect-6.0.11 lib/rhoconnect/read_state.rb
rhoconnect-5.5.18 lib/rhoconnect/read_state.rb
rhoconnect-5.5.17 lib/rhoconnect/read_state.rb
rhoconnect-5.5.15 lib/rhoconnect/read_state.rb
rhoconnect-5.5.0.22 lib/rhoconnect/read_state.rb
rhoconnect-5.5.2 lib/rhoconnect/read_state.rb
rhoconnect-5.5.0.7 lib/rhoconnect/read_state.rb
rhoconnect-5.5.0.3 lib/rhoconnect/read_state.rb
rhoconnect-5.5.0 lib/rhoconnect/read_state.rb
rhoconnect-5.1.1 lib/rhoconnect/read_state.rb
rhoconnect-4.0.4 lib/rhoconnect/read_state.rb
rhoconnect-4.0.3 lib/rhoconnect/read_state.rb
rhoconnect-4.0.2 lib/rhoconnect/read_state.rb
rhoconnect-4.0.1 lib/rhoconnect/read_state.rb
rhoconnect-4.0.0 lib/rhoconnect/read_state.rb