Module: RedisAssist::Callbacks::ClassMethods
- Defined in:
- lib/redis_assist/callbacks.rb
Constant Summary collapse
- CALLBACK_TYPES =
[ :on_load, :before_validation, :before_create, :before_save, :before_update, :after_create, :after_save, :after_update, :after_delete, :after_update ]
Instance Method Summary collapse
Instance Method Details
#callbacks ⇒ Object
30 31 32 |
# File 'lib/redis_assist/callbacks.rb', line 30 def callbacks @callbacks ||= {} end |
#define_callbacks ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/redis_assist/callbacks.rb', line 34 def define_callbacks CALLBACK_TYPES.each do |callback_type| define_singleton_method(callback_type) do |*callback_methods, &block| add_callback(callback_type) do |instance| callback_methods.each do |callback_method| instance.send callback_method end block.call(instance) if block end end end end |