Module: Redis::Actions::Destroying
- Defined in:
- lib/redis/actions/destroying.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
2 3 4 5 6 7 8 9 |
# File 'lib/redis/actions/destroying.rb', line 2 def self.included(base) base.class_eval do extend Redis::Actions::Destroying::ClassMethods define_model_callbacks :destroy class_inheritable_array :within_destroy_blocks self.within_destroy_blocks ||= [] end end |
Instance Method Details
#destroy ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/redis/actions/destroying.rb', line 11 def destroy unless new_record? # run_callbacks(:before_destroy) run_callbacks(:destroy) do transaction do connection.del id within_destroy_blocks.each do |method_name_or_block| if method_name_or_block.kind_of?(String) || method_name_or_block.kind_of?(Symbol) send method_name_or_block else method_name_or_block.call self end end end end end end |