Sha256: 1a3fdb675321be49f07ca2ccfe4336542948b4289983812c28f0d6306f48043a

Contents?: true

Size: 1.52 KB

Versions: 8

Compression:

Stored size: 1.52 KB

Contents

# frozen_string_literal: true

class ActiveOrm::Redis::Set < ActiveOrm::Redis::Base
  class << self

    def find(key)
      value = client.smembers(normalize_key(key))
      metatransform(value)
    end

    def combine(*args)
      value = client.sunion(*args)
      metatransform(value)
    end

    def difference(*args)
      value = client.sdiff(*args)
      metatransform(value)
    end

    def intersection(key, *args)
      value = client.sinter(normalize_key(key), *args)
      metatransform(value)
    end

    def sample(key, value = 1)
      value = client.srandmember(normalize_key(key), value)
      metatransform(value)
    end

    def value?(key, value)
      client.sismember(normalize_key(key), value)
    end

    def count(key)
      client.scard(normalize_key(key))
    end

    def create(key, *args)
      client.sadd(normalize_key(key), args)
    end

    def create_combination(key, *args)
      client.sunionstore(normalize_key(key), args)
    end

    def create_difference(key, *args)
      client.sdiffstore(normalize_key(key), *args)
    end

    def create_intersection(key, *args)
      client.sinterstore(normalize_key(key), args)
    end

    def move(key, destination, value)
      client.smove(normalize_key(key), destination.to_s, value)
    end

    def destroy(key, *args)
      client.srem(normalize_key(key), *args)
    end

    def destroy_random(key)
      client.spop(normalize_key(key))
    end

    def scan(key, cursor, opts = {})
      client.sscan(normalize_key(key), cursor, opts)
    end

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
active_orm-5.1.0 lib/active_orm/redis/set.rb
active_orm-5.0.6 lib/active_orm/redis/set.rb
active_orm-5.0.5 lib/active_orm/redis/set.rb
active_orm-5.0.4 lib/active_orm/redis/set.rb
active_orm-5.0.3 lib/active_orm/redis/set.rb
active_orm-5.0.2 lib/active_orm/redis/set.rb
active_orm-5.0.1 lib/active_orm/redis/set.rb
active_orm-5.0.0 lib/active_orm/redis/set.rb