Class: Ohm::Model::Set

Inherits:
Collection show all
Defined in:
lib/ohm.rb

Direct Known Subclasses

Index

Constant Summary

Raw =
Ohm::Set

Instance Method Summary (collapse)

Methods inherited from Collection

#<<, #[], #all, #clear, #concat, #delete, #each, #empty?, #first, #include?, #initialize, #key, #replace, #size, #sort, #sort_by

Constructor Details

This class inherits a constructor from Ohm::Model::Collection

Instance Method Details

- (Object) except(hash)

Returns the difference between the receiver and the passed sets.

Examples:

@events = Event.find(public: true).except(status: "sold_out")


221
222
223
# File 'lib/ohm.rb', line 221

def except(hash)
  apply(:sdiffstore, hash, :-)
end

- (Object) find(hash)

Returns an intersection with the sets generated from the passed hash.

Examples:

@events = Event.find(public: true)

# You can combine the result with sort and other set operations:
@events.sort_by(:name)

See Also:



213
214
215
# File 'lib/ohm.rb', line 213

def find(hash)
  apply(:sinterstore, hash, :+)
end

- (Object) inspect



201
202
203
# File 'lib/ohm.rb', line 201

def inspect
  "#<Set (#{model}): #{all.inspect}>"
end