Sha256: e64212ea38e932462df45518b5db7dd9b3a2d02bbcb87cc9b581692b955d6703

Contents?: true

Size: 665 Bytes

Versions: 2

Compression:

Stored size: 665 Bytes

Contents

class Kredis::Types::Set < Kredis::Types::Proxying
  proxying :smembers, :sadd, :srem, :multi, :del, :sismember, :scard, :spop

  attr_accessor :typed

  def members
    strings_to_types(smembers || [], typed).sort
  end
  alias to_a members

  def add(*members)
    sadd types_to_strings(members) if members.flatten.any?
  end
  alias << add

  def remove(*members)
    srem types_to_strings(members) if members.flatten.any?
  end

  def replace(*members)
    multi do
      del
      add members
    end
  end

  def include?(member)
    sismember type_to_string(member)
  end

  def size
    scard
  end

  def take
    spop
  end

  def clear
    del
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kredis-0.2.1 lib/kredis/types/set.rb
kredis-0.2.0 lib/kredis/types/set.rb