lib/timeline_fu/fires.rb in giraffesoft-timeline_fu-0.2.0 vs lib/timeline_fu/fires.rb in giraffesoft-timeline_fu-0.3.0
- old
+ new
@@ -5,9 +5,16 @@
end
module ClassMethods
def fires(event_type, opts)
raise ArgumentError, "Argument :on is mandatory" unless opts.has_key?(:on)
+
+ # Array provided, set multiple callbacks
+ if opts[:on].kind_of?(Array)
+ opts[:on].each { |on| fires(event_type, opts.merge({:on => on})) }
+ return
+ end
+
opts[:subject] = :self unless opts.has_key?(:subject)
method_name = :"fire_#{event_type}_after_#{opts[:on]}"
define_method(method_name) do
create_options = [:actor, :subject, :secondary_subject].inject({}) do |memo, sym|