party_boy 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/lib/party_boy.rb +12 -12
  3. data/party_boy.gemspec +2 -2
  4. metadata +2 -2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.5
1
+ 0.1.6
data/lib/party_boy.rb CHANGED
@@ -78,8 +78,8 @@ module Party
78
78
  def follow(something)
79
79
  if blocked_by?(something)
80
80
  raise(Party::Boy::StalkerError, "#{super_class_name} #{self.id} has been blocked by #{super_class_name(something)} #{something.id} but is trying to follow them")
81
- else
82
- Relationship.create(:requestor => self, :requestee => something, :restricted => false) if !(blocked_by?(something) || following?(something))
81
+ elsif !following?(something)
82
+ Relationship.create(:requestor => self, :requestee => something, :restricted => false)
83
83
  end
84
84
  end
85
85
 
@@ -108,9 +108,9 @@ module Party
108
108
  exact_class = type && type.to_s.classify
109
109
  results = relationships_from(super_class)
110
110
  if super_class && exact_class && super_class != exact_class
111
- results.collect{|r| r.requestor.class.name == exact_class && r.requestor || nil}.compact
111
+ results.collect{|relationship| requestor = relationship.requestor; requestor.class.name == exact_class && requestor || nil}.compact
112
112
  else
113
- results.collect{|r| r.requestor}
113
+ results.collect{|relationship| relationship.requestor}
114
114
  end
115
115
 
116
116
  end
@@ -120,9 +120,9 @@ module Party
120
120
  exact_class = type && type.to_s.classify
121
121
  results = relationships_to(super_class)
122
122
  if super_class && exact_class && super_class != exact_class
123
- results.collect{|r| r.requestee.class.name == exact_class && r.requestee || nil}.compact
123
+ results.collect{|relationship| requestee = relationship.requestee; requestee.class.name == exact_class && requestee || nil}.compact
124
124
  else
125
- results.collect{|r| r.requestee}
125
+ results.collect{|relationship| relationship.requestee}
126
126
  end
127
127
  end
128
128
 
@@ -131,7 +131,7 @@ module Party
131
131
  end
132
132
 
133
133
  def extended_network(type = nil)
134
- network(type).collect{|f| f.methods.include?('network') && f.network(type) || []}.flatten.uniq
134
+ network(type).collect{|friend| friend.methods.include?('network') && friend.network(type) || []}.flatten.uniq
135
135
  end
136
136
 
137
137
  def method_missing(method, *args)
@@ -162,11 +162,11 @@ module Party
162
162
  module FriendlyInstanceMethods
163
163
 
164
164
  def friends
165
- (outgoing_friendships.accepted + incoming_friendships.accepted).collect{|r| [r.requestor, r.requestee]}.flatten.uniq - [self]
165
+ (outgoing_friendships.accepted + incoming_friendships.accepted).collect{|relationship| [relationship.requestor, relationship.requestee]}.flatten.uniq - [self]
166
166
  end
167
167
 
168
168
  def extended_network
169
- friends.collect{|f| f.methods.include?('friends') && f.friends || []}.flatten.uniq - [self]
169
+ friends.collect{|friend| friend.methods.include?('friends') && friend.friends || []}.flatten.uniq - [self]
170
170
  end
171
171
 
172
172
  def outgoing_friend_requests
@@ -193,8 +193,8 @@ module Party
193
193
  end
194
194
 
195
195
  def request_friendship(friendship_or_something)
196
- rel = relationship_from(friendship_or_something)
197
- rel.nil? && Relationship.create(:requestor => self, :requestee => friendship_or_something, :restricted => true) || (rel.requestee == self && rel.update_attributes(:restricted => false))
196
+ relationship = relationship_from(friendship_or_something)
197
+ relationship.nil? && Relationship.create(:requestor => self, :requestee => friendship_or_something, :restricted => true) || (relationship.requestee == self && relationship.update_attributes(:restricted => false))
198
198
  end
199
199
 
200
200
  def deny_friendship(friendship_or_something)
@@ -208,7 +208,7 @@ module Party
208
208
 
209
209
  def relationship_from(friendship_or_something)
210
210
  if friendship_or_something && friendship_or_something.class == Relationship
211
- raise(Party::Boy::IdentityTheftError, "#{self.class.name} with id of #{self.id} tried to access Relationship #{friendship_or_something.id}") if !(friendship_or_something.requestor == self || friendship_or_something.requestee == self)
211
+ raise(Party::Boy::IdentityTheftError, "#{self.class.name} with id of #{self.id} tried to access Relationship #{friendship_or_something.id}") if !(friendship_or_something.requestor == self || friendship_or_something.requestee == self)
212
212
  friendship_or_something
213
213
  else
214
214
  arr = friendship_or_something && [self.id, super_class_name, super_class_name(friendship_or_something), friendship_or_something.id]
data/party_boy.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{party_boy}
8
- s.version = "0.1.5"
8
+ s.version = "0.1.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Mike Nelson"]
12
- s.date = %q{2010-01-30}
12
+ s.date = %q{2010-02-02}
13
13
  s.description = %q{Models relationships between AR models. Allows you to follow, friend, and block other AR's. Consists of two mixins: acts_as_followable and acts_as_friend. These options allow an AR to inherit either a twitter-like follower system or a facebook-like friend system.}
14
14
  s.email = %q{mdnelson30@gmail.com}
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: party_boy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Nelson
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-30 00:00:00 -05:00
12
+ date: 2010-02-02 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency