Class: Sohm::MutableSet

Inherits:
Set show all
Defined in:
lib/sohm.rb

Instance Attribute Summary

Attributes inherited from Set

#key, #model, #namespace

Instance Method Summary collapse

Methods inherited from Set

#initialize

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