Class: Sohm::MutableSet
Instance Attribute Summary
Attributes inherited from Set
Instance Method Summary collapse
-
#add(model) ⇒ Object
(also: #<<)
Add a model directly to the set.
-
#delete(model) ⇒ Object
Remove a model directly from the set.
Methods inherited from Set
Methods inherited from BasicSet
#[], #exists?, #ids, #include?, #sample, #size
Methods included from Collection
#each, #empty?, #fetch, #to_a, #to_json
Constructor Details
This class inherits a constructor from Sohm::Set
Instance Method Details
#add(model) ⇒ Object Also known as: <<
Add a model directly to the set.
Example:
user = User.create
post = Post.create
user.posts.add(post)
455 456 457 |
# File 'lib/sohm.rb', line 455 def add(model) redis.call("SADD", key, model.id) end |
#delete(model) ⇒ Object
Remove a model directly from the set.
Example:
user = User.create
post = Post.create
user.posts.delete(post)
470 471 472 |
# File 'lib/sohm.rb', line 470 def delete(model) redis.call("SREM", key, model.id) end |