Sha256: 7da3957b9699290c8a87d8023bfdcbcb6b10e24264ef93724ca912cb46e5c26d

Contents?: true

Size: 1.01 KB

Versions: 15

Compression:

Stored size: 1.01 KB

Contents

module Rhosync  
  class ReadState < Model
    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.flash_data("#{class_prefix(self)}:#{app_id}:*")
    end
    
    def self.delete_user(params)
      puts "#{class_prefix(self)}:#{params[:app_id]}:#{params[:user_id]}:#{params[:source_name]}:*"
      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

15 entries across 15 versions & 1 rubygems

Version Path
rhosync-2.1.18.beta2 lib/rhosync/read_state.rb
rhosync-2.1.18.beta1 lib/rhosync/read_state.rb
rhosync-2.1.17 lib/rhosync/read_state.rb
rhosync-2.1.17.beta7 lib/rhosync/read_state.rb
rhosync-2.1.17.beta6 lib/rhosync/read_state.rb
rhosync-2.1.17.beta5 lib/rhosync/read_state.rb
rhosync-2.1.17.beta4 lib/rhosync/read_state.rb
rhosync-2.1.17.beta3 lib/rhosync/read_state.rb
rhosync-2.1.17.beta2 lib/rhosync/read_state.rb
rhosync-2.1.17.beta1 lib/rhosync/read_state.rb
rhosync-2.1.16 lib/rhosync/read_state.rb
rhosync-2.1.15 lib/rhosync/read_state.rb
rhosync-2.1.14 lib/rhosync/read_state.rb
rhosync-2.1.13 lib/rhosync/read_state.rb
rhosync-2.1.12 lib/rhosync/read_state.rb