Module: Horde::Actions::FollowMethods::ActorMethods

Extended by:
ActiveSupport::Concern
Defined in:
lib/horde/actions/follow.rb

Overview

methods for user, usually User class in your app.

Instance Method Summary collapse

Instance Method Details

#follow(target, options = {}) ⇒ Object

user follow something.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/horde/actions/follow.rb', line 25

def follow(target, options = {})
  pks  = {:actor_id => self.id, 
          :target_id => target.id,
          :target_type => target.class.name
         }.merge(options)
  
  follow = ::Horde::Follow.where(pks).first
  if follow
    # do nothing
  else
    params = pks.merge(options)
    follow = ::Horde::Follow.create(params)
  end

  target.run_hook(:after_follow, follow)

  follow
end