Class: Conflow::Redis::SetField Private
- Includes:
- Enumerable
- Defined in:
- lib/conflow/redis/set_field.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Represents Redis list. It’s methods mirror most used Set methods.
Instance Attribute Summary
Attributes inherited from Field
Instance Method Summary collapse
-
#add(*values) ⇒ String
private
Adds one or more elements to the set.
-
#overwrite(enumerable) ⇒ String
private
Removes old values from the set and overrides them with new.
-
#size ⇒ Integer
private
Number of elements in the set.
-
#to_a ⇒ Array
(also: #to_ary)
private
Returns array with set values.
Methods inherited from Field
Constructor Details
This class inherits a constructor from Conflow::Redis::Field
Instance Method Details
#add(*values) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Adds one or more elements to the set.
16 17 18 |
# File 'lib/conflow/redis/set_field.rb', line 16 def add(*values) command :sadd, [key, values] end |
#overwrite(enumerable) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Removes old values from the set and overrides them with new.
28 29 30 31 32 33 34 35 |
# File 'lib/conflow/redis/set_field.rb', line 28 def overwrite(enumerable) redis.with do |conn| conn.pipelined do conn.del(key) conn.sadd(key, enumerable) end end end |
#size ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns Number of elements in the set.
21 22 23 |
# File 'lib/conflow/redis/set_field.rb', line 21 def size command :scard, [key] end |
#to_a ⇒ Array Also known as: to_ary
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns array with set values
39 40 41 |
# File 'lib/conflow/redis/set_field.rb', line 39 def to_a command :smembers, [key] end |