Module: RSolr::Ext::Model::Callbacks

Defined in:
lib/rsolr-ext/model.rb

Overview

Class level methods for altering object instances

Instance Method Summary collapse

Instance Method Details

#after_initialize(&blk) ⇒ Object

method that only accepts a block The block is executed when an object is created via #new -> SolrDoc.new The blocks scope is the instance of the object.



19
20
21
# File 'lib/rsolr-ext/model.rb', line 19

def after_initialize(&blk)
  hooks << blk
end

#clear_after_initialize_blocks!Object

Removes the current set of after_initialize blocks. You would use this if you wanted to open a class back up, but clear out the previously defined blocks.



26
27
28
# File 'lib/rsolr-ext/model.rb', line 26

def clear_after_initialize_blocks!
  @hooks = []
end

#hooksObject

creates the @hooks container (“hooks” are blocks or procs). returns an array



32
33
34
# File 'lib/rsolr-ext/model.rb', line 32

def hooks
  @hooks ||= []
end