has_friends_ti2 0.0.23 → 0.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 389eb6486b904c492293fa6aa209347d677063e6
4
- data.tar.gz: 6d2f482e5675ba004e4185d92ef5d331f3bc211e
3
+ metadata.gz: 46134091af111bbafba408d096988dd9a37be990
4
+ data.tar.gz: 8c19c445256cbce567ba0ad6fee9d0766390f2ea
5
5
  SHA512:
6
- metadata.gz: c11bbf6724dea616054680cf6445431cad5f6485948e481ec14835b929a0b3e6c1a3f402b495b760eeefc3993aaaf7254b0001979ca6a17c3ea110be61430ea8
7
- data.tar.gz: 6d40febbcfc214836431a44b69e2b20ac7d3cdefb6d4a24b0e0ebdeea53388f375a5fa596038dad4b0d7c80e4c93dc90796660227cdb87ce9c5ca7daa85987bf
6
+ metadata.gz: edffd028a77abd74a63f49557f2afdb5c848024782d00809e6a3448a2ebab7dee961c49340cd0940f589ca6e76e1113f71112477b9fc45477814f51fcfb4249c
7
+ data.tar.gz: 8a327c4e363b35a04465c916df7d837b4dc9afffa313ea952db601edcf9e4672e948b6afa5771d849c6e27660a921e3ae20dca69a00b4f62222dbf1aa5aa3dd3
@@ -2,11 +2,12 @@ module HasFriends
2
2
 
3
3
  module Friends
4
4
  def self.included(receiver)
5
- receiver.extend HasFriends::Friends::ClassMethods
5
+ receiver.extend ClassMethods
6
+ receiver.send :include, InstanceMethods
6
7
  end
8
+
7
9
  module ClassMethods
8
10
  def has_friends
9
- include HasFriends::Friends::InstanceMethods
10
11
  has_many :friendships
11
12
  has_many :friends, :through => :friendships, :source => :friend#,-> { where( status: 'accepted')} #"friendships.status = 'accepted'"
12
13
  after_destroy :destroy_all_friendships
@@ -14,6 +15,7 @@ module HasFriends
14
15
  end
15
16
 
16
17
  module InstanceMethods
18
+
17
19
  def be_friends_with friend
18
20
  # no user object
19
21
  return nil, Friendship::STATUS_FRIEND_IS_REQUIRED unless friend
@@ -50,11 +52,14 @@ module HasFriends
50
52
  return friendship, Friendship::STATUS_REQUESTED
51
53
  end
52
54
 
53
-
54
55
  def friends?(friend)
55
56
  friendship = friendship_for(friend)
56
57
  friendship && friendship.accepted?
57
58
  end
59
+ def are_friends?(friend)
60
+ friendship = friendship_for(friend)
61
+ friendship && friendship.accepted?
62
+ end
58
63
 
59
64
  def friendship_for(friend)
60
65
  friendships.where(:friend_id => friend.id).first
@@ -70,6 +75,8 @@ module HasFriends
70
75
  Friendship.delete_all({:friend_id => id})
71
76
  end
72
77
  end
78
+
79
+
73
80
  end
74
81
 
75
82
  end
@@ -1,3 +1,3 @@
1
1
  module HasFriends
2
- VERSION = "0.0.23"
2
+ VERSION = "0.0.26"
3
3
  end
@@ -31,6 +31,10 @@ describe 'has_friends' do
31
31
  it "should respond to friends? method" do
32
32
  expect( @vader ).to respond_to :friends?
33
33
  end
34
+
35
+ it "should respond to are friends? method" do
36
+ expect( @vader ).to respond_to :are_friends?
37
+ end
34
38
  end
35
39
 
36
40
  describe "friends" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_friends_ti2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.23
4
+ version: 0.0.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tiago D Cipriano