Sha256: 8b78af8a177e473ca08b8316b511720aba211815bce76eb9dbf7aec76b61138a

Contents?: true

Size: 1005 Bytes

Versions: 23

Compression:

Stored size: 1005 Bytes

Contents

class MockAdapter < Rhoconnect::Model::Base
  def initialize(source) 
    super(source)
  end
 
  def login
    true
  end

 def query(params=nil)
   Store.lock(lock_name,1) do
     @result = Store.get_data(db_name)
   end
   @result
 end
 
 def create(create_hash)
   id = create_hash['mock_id']
   Store.lock(lock_name,1) do
     Store.put_data(db_name,{id=>create_hash},true) if id
   end
   id
 end

 def update(update_hash)
   id = update_hash.delete('id')
   return unless id
   Store.lock(lock_name,1) do
     data = Store.get_data(db_name)
     return unless data and data[id]
     update_hash.each do |attrib,value|
       data[id][attrib] = value
     end
     Store.put_data(db_name,data)
   end
 end

 def delete(delete_hash)
   id = delete_hash.delete('id')
   Store.lock(lock_name,1) do
     Store.delete_data(db_name,{id=>delete_hash}) if id
   end
 end

 def db_name
   "test_db_storage:#{@source.app_id}:#{@source.user_id}"
 end
 
 def lock_name
   "lock:#{db_name}"
 end
 
 private
 
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
rhoconnect-7.6.0 bench/benchapp/models/ruby/mock_adapter.rb
rhoconnect-7.5.1 bench/benchapp/models/ruby/mock_adapter.rb
rhoconnect-7.4.1 bench/benchapp/models/ruby/mock_adapter.rb
rhoconnect-7.1.17 bench/benchapp/models/ruby/mock_adapter.rb
rhoconnect-6.2.0 bench/benchapp/models/ruby/mock_adapter.rb
rhoconnect-6.0.11 bench/benchapp/models/ruby/mock_adapter.rb
rhoconnect-5.5.18 bench/benchapp/models/ruby/mock_adapter.rb
rhoconnect-5.5.17 bench/benchapp/models/ruby/mock_adapter.rb
rhoconnect-5.5.15 bench/benchapp/models/ruby/mock_adapter.rb
rhoconnect-5.5.0.22 bench/benchapp/models/ruby/mock_adapter.rb
rhoconnect-5.5.2 bench/benchapp/models/ruby/mock_adapter.rb
rhoconnect-5.5.0.7 bench/benchapp/models/ruby/mock_adapter.rb
rhoconnect-5.5.0.3 bench/benchapp/models/ruby/mock_adapter.rb
rhoconnect-5.5.0 bench/benchapp/models/ruby/mock_adapter.rb
rhoconnect-5.1.1 bench/benchapp/models/ruby/mock_adapter.rb
rhoconnect-4.0.4 bench/benchapp/models/ruby/mock_adapter.rb
rhoconnect-4.0.3 bench/benchapp/models/ruby/mock_adapter.rb
rhoconnect-4.0.2 bench/benchapp/models/ruby/mock_adapter.rb
rhoconnect-4.0.1 bench/benchapp/models/ruby/mock_adapter.rb
rhoconnect-4.0.0 bench/benchapp/models/ruby/mock_adapter.rb