Class Ohm::MutableSet
In: lib/ohm.rb
Parent: Set

Methods

<<   add   delete   replace  

Public Instance methods

<<(model)

Alias for add

Add a model directly to the set.

Example:

  user = User.create
  post = Post.create

  user.posts.add(post)

Remove a model directly from the set.

Example:

  user = User.create
  post = Post.create

  user.posts.delete(post)

Replace all the existing elements of a set with a different collection of models. This happens atomically in a MULTI-EXEC block.

Example:

  user = User.create
  p1 = Post.create
  user.posts.add(p1)

  p2, p3 = Post.create, Post.create
  user.posts.replace([p2, p3])

  user.posts.include?(p1)
  # => false

[Validate]