Module: Interest::FollowRequestable::FollowRequest

Extended by:
ActiveSupport::Concern
Included in:
Following
Defined in:
lib/interest/follow_requestable/follow_request.rb

Instance Method Summary collapse

Instance Method Details

#acceptObject



12
13
14
# File 'lib/interest/follow_requestable/follow_request.rb', line 12

def accept
  update status: "accepted"
end

#accept!Object



16
17
18
# File 'lib/interest/follow_requestable/follow_request.rb', line 16

def accept!
  update! status: "accepted"
end

#accept_mutual_followObject



20
21
22
# File 'lib/interest/follow_requestable/follow_request.rb', line 20

def accept_mutual_follow
  transaction { accept and mutual }
end

#accept_mutual_follow!Object



24
25
26
# File 'lib/interest/follow_requestable/follow_request.rb', line 24

def accept_mutual_follow!
  transaction { accept! and mutual! }
end

#rejectObject Also known as: reject!



28
29
30
# File 'lib/interest/follow_requestable/follow_request.rb', line 28

def reject
  destroy
end

#should_validate_follow_request_relationships?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/interest/follow_requestable/follow_request.rb', line 34

def should_validate_follow_request_relationships?
  pending? and follower.is_a?(ActiveRecord::Base) and followee.is_a?(ActiveRecord::Base)
end

#validate_follow_request_relationshipsObject



38
39
40
41
42
# File 'lib/interest/follow_requestable/follow_request.rb', line 38

def validate_follow_request_relationships
  errors.add :follower, :invalid unless follower.follow_requester?
  errors.add :followee, :invalid unless followee.follow_requestee?
  errors.add :followee, :rejected if follower.follow_requester? and not follower.valid_follow_request_for?(followee)
end