Stream 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/stream/fires.rb +4 -4
- data/stream.gemspec +1 -1
- metadata +1 -1
data/lib/stream/fires.rb
CHANGED
@@ -5,18 +5,18 @@ module Stream
|
|
5
5
|
end
|
6
6
|
|
7
7
|
module ClassMethods
|
8
|
-
def fires(
|
8
|
+
def fires(activity_type, opts)
|
9
9
|
raise ArgumentError, "Argument :on is mandatory" unless opts.has_key?(:on)
|
10
10
|
|
11
11
|
# Array provided, set multiple callbacks
|
12
12
|
if opts[:on].kind_of?(Array)
|
13
|
-
opts[:on].each { |on| fires(
|
13
|
+
opts[:on].each { |on| fires(activity_type, opts.merge({:on => on})) }
|
14
14
|
return
|
15
15
|
end
|
16
16
|
|
17
17
|
opts[:subject] = :self unless opts.has_key?(:subject)
|
18
18
|
|
19
|
-
method_name = :"fire_#{
|
19
|
+
method_name = :"fire_#{activity_type}_after_#{opts[:on]}"
|
20
20
|
define_method(method_name) do
|
21
21
|
create_options = [:actor, :subject, :secondary_subject].inject({}) do |memo, sym|
|
22
22
|
if opts[sym]
|
@@ -30,7 +30,7 @@ module Stream
|
|
30
30
|
end
|
31
31
|
memo
|
32
32
|
end
|
33
|
-
create_options[:
|
33
|
+
create_options[:activity_type] = activity_type.to_s
|
34
34
|
|
35
35
|
Activity.create!(create_options)
|
36
36
|
end
|
data/stream.gemspec
CHANGED