Module: Timeline::Track::ClassMethods

Defined in:
lib/timeline/track.rb

Instance Method Summary collapse

Instance Method Details

#track(name, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/timeline/track.rb', line 5

def track(name, options={})
  @name = name
  @callback = options.delete :on
  @callback ||= :create
  @actor = options.delete :actor
  @actor ||= :creator
  @object = options.delete :object
  @target = options.delete :target
  @followers = options.delete :followers
  @followers ||= :followers
  @mentionable = options.delete :mentionable

  method_name = "track_#{@name}_after_#{@callback}".to_sym
  define_activity_method method_name, actor: @actor, object: @object, target: @target, followers: @followers, verb: name, mentionable: @mentionable

  send "after_#{@callback}".to_sym, method_name, if: options.delete(:if)
end