Skip to content

Commit

Permalink
Add sadd_returns_boolean + sadd? method (#217)
Browse files Browse the repository at this point in the history
* Add sadd_returns_boolean + sadd? method

* adding comment about said var

Co-authored-by: Michael Bianco <iloveitaly@gmail.com>
  • Loading branch information
radar and iloveitaly committed Dec 13, 2022
1 parent f7094ed commit b949b5d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/redis/namespace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ class Namespace
"rpush" => [ :first ],
"rpushx" => [ :first ],
"sadd" => [ :first ],
"sadd?" => [ :first ],
"scard" => [ :first ],
"scan" => [ :scan_style, :second ],
"scan_each" => [ :scan_style, :all ],
Expand Down Expand Up @@ -239,6 +240,13 @@ class Namespace
# Support 1.8.7 by providing a namespaced reference to Enumerable::Enumerator
Enumerator = Enumerable::Enumerator unless defined?(::Enumerator)

# This is used by the Redis gem to determine whether or not to display that deprecation message.
@sadd_returns_boolean = true

class << self
attr_accessor :sadd_returns_boolean
end

attr_writer :namespace
attr_reader :redis
attr_accessor :warning
Expand Down
5 changes: 5 additions & 0 deletions spec/redis_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,11 @@
expect(values).to match_array(['banana', 'eggplant'])
end

it "should add a new member" do
expect(@namespaced.sadd?('foo', 1)).to eq(true)
expect(@namespaced.sadd?('foo', 1)).to eq(false)
end

it "should add namespace to sort" do
@namespaced.sadd('foo', 1)
@namespaced.sadd('foo', 2)
Expand Down

0 comments on commit b949b5d

Please sign in to comment.