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.



35
36
37
# File 'lib/rsolr-ext/model.rb', line 35

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.



42
43
44
# File 'lib/rsolr-ext/model.rb', line 42

def clear_after_initialize_blocks!
  @hooks = []
end

#hooksObject

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



48
49
50
# File 'lib/rsolr-ext/model.rb', line 48

def hooks
  @hooks ||= []
end