Method: Hyperactive::Index::Indexable::ClassMethods#reject
- Defined in:
- lib/hyperactive/index.rb
#reject(name, &block) ⇒ Object
Will define a method called name that will include all existing instances of this class that when yielded to block does not return true. Will only return instances saved after this rejector is defined.
196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/hyperactive/index.rb', line 196 def reject(name, &block) #:yields: instance key = collection_key(name) Archipelago::Pirate::BLACKBEARD[key] ||= Hyperactive::Hash::Head.get_instance self.class.class_eval do define_method(name) do Archipelago::Pirate::BLACKBEARD[key] end end self.save_hooks << MatchSaver.new(key, block, :reject) self.destroy_hooks << MatchSaver.new(key, block, :delete_unless_match) end |