lib/mongo_mapper/plugins/callbacks.rb in pwnash-mongo_mapper-0.7.5 vs lib/mongo_mapper/plugins/callbacks.rb in pwnash-mongo_mapper-0.7.6
- old
+ new
@@ -1,5 +1,6 @@
+# encoding: UTF-8
# Almost all of this callback stuff is pulled directly from ActiveSupport
# in the interest of support rails 2 and 3 at the same time and is the
# same copyright as rails.
module MongoMapper
module Plugins
@@ -74,11 +75,11 @@
result = super
run_callbacks(:after_destroy)
result
end
- def run_callbacks(kind, options = {}, &block)
+ def run_callbacks(kind, options={}, &block)
callback_chain_method = "#{kind}_callback_chain"
return unless self.class.respond_to?(callback_chain_method)
self.class.send(callback_chain_method).run(self, options, &block)
self.embedded_associations.each do |association|
if association.one?
@@ -120,11 +121,11 @@
methods, options = extract_options(*methods, &block)
methods.map! { |method| Callback.new(kind, method, options) }
new(methods)
end
- def run(object, options = {}, &terminator)
+ def run(object, options={}, &terminator)
enumerator = options[:enumerator] || :each
unless block_given?
send(enumerator) { |callback| callback.call(object) }
else
@@ -167,10 +168,10 @@
end
class Callback
attr_reader :kind, :method, :identifier, :options
- def initialize(kind, method, options = {})
+ def initialize(kind, method, options={})
@kind = kind
@method = method
@identifier = options[:identifier]
@options = options
end