Module: Interest::Followable::Following

Extended by:
ActiveSupport::Concern
Included in:
Following
Defined in:
lib/interest/followable/following.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#accepted?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/interest/followable/following.rb', line 29

def accepted?
  status == "accepted"
end

#mutualObject



37
38
39
# File 'lib/interest/followable/following.rb', line 37

def mutual
  followee.follow(follower)
end

#mutual!Object



41
42
43
# File 'lib/interest/followable/following.rb', line 41

def mutual!
  followee.follow!(follower)
end

#pending?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/interest/followable/following.rb', line 33

def pending?
  status == "pending"
end

#should_validate_following_relationships?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/interest/followable/following.rb', line 45

def should_validate_following_relationships?
  accepted? and follower.is_a?(ActiveRecord::Base) and followee.is_a?(ActiveRecord::Base)
end

#validate_following_relationshipsObject



49
50
51
52
53
# File 'lib/interest/followable/following.rb', line 49

def validate_following_relationships
  errors.add :follower, :invalid unless follower.follower?
  errors.add :followee, :invalid unless followee.followee?
  errors.add :followee, :rejected if follower.follower? and not follower.valid_following_for?(followee)
end