Sha256: d9bf4a4630160d8781f5b8f4b92a2e71b40008feed9b1e56017dda94473591b9

Contents?: true

Size: 843 Bytes

Versions: 5

Compression:

Stored size: 843 Bytes

Contents

module Rhoconnect  
  class ReadState < Model
    field :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[:retry_counter] ||= 0
      super(fields,{})
    end
  
    def self.load(params)
      super(get_id(params),{})
    end
    
    def self.delete(app_id)
      Store.flash_data("#{class_prefix(self)}:#{app_id}:*")
    end
    
    def self.delete_user(params)
      Store.flash_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

5 entries across 5 versions & 1 rubygems

Version Path
rhoconnect-3.0.2 lib/rhoconnect/read_state.rb
rhoconnect-3.0.1 lib/rhoconnect/read_state.rb
rhoconnect-3.0.0 lib/rhoconnect/read_state.rb
rhoconnect-3.0.0.rc1 lib/rhoconnect/read_state.rb
rhoconnect-3.0.0.beta3 lib/rhoconnect/read_state.rb