acts_as_important 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a15ea261b84c9494ce983efa27865b1af4123640
4
- data.tar.gz: e43c33d759fc7698577a58d27096790b7ddf5b2e
3
+ metadata.gz: 3295e8893c72bc3dc31bbe3b0703c001194edcf6
4
+ data.tar.gz: 67c0fecfa9d710db5c4d80478b3fbdd8d1cae6be
5
5
  SHA512:
6
- metadata.gz: 16b6c8164c8eb716e28d1c84855ef909b95825f26ef56b02e102e6edd1300ba3a3769d066fa3e2820ff3538d4435ce99e9551f729e0d358cd06a089f74b005b3
7
- data.tar.gz: c437495f64b0432e384d14d479d0c829db32a09104e3dede3e1d6d79505b94ef3bd472f82572520197ae54a8588b0d610b9fecbdb14c1b150ea4d0034e345f5a
6
+ metadata.gz: 7f60968802b237e5a381e321aa25b1f6eeafd1787f4ec6006ad1ad86ca576f26a7907c691fc2b11d8068be5fe5bcd009d4c8769493c554fd8bc010170b437bd4
7
+ data.tar.gz: 3e8e50df1126e95207c35bdc8f7d5806c9825f621732368b02d8fc09dda4411114e276b401c9123a1c2ba648e3f3ef46d35db66fdeccbe2e46be5f9ae06e7d3b
@@ -2,22 +2,22 @@ module ActsAsImportant
2
2
  module ActMethod #:nodoc:
3
3
  def acts_as_important(options = {})
4
4
  has_many :importance_indicators, :as => :record, :dependent => :destroy
5
-
6
- has_many :active_importance_indicators, :class_name => 'ImportanceIndicator', :as => :record, :dependent => :destroy, :conditions =>['active = ?', true]
5
+
6
+ has_many :active_importance_indicators, lambda { where ['active = ?', true] }, :class_name => 'ImportanceIndicator', :as => :record, :dependent => :destroy
7
7
  has_many :concerned_users, :through => :active_importance_indicators, :source => :user
8
8
 
9
9
  # Left joins importance indicators from a particular user
10
- scope :with_user_importance, lambda{|user| joins("LEFT OUTER JOIN importance_indicators ON importance_indicators.record_id = #{quoted_table_name}.id AND importance_indicators.record_type = '#{name}' AND importance_indicators.user_id = #{user.id}")}
11
-
12
- scope :important_to, lambda{|user| joins(:importance_indicators).where("importance_indicators.user_id = #{user.id} AND importance_indicators.active = true")}
13
- scope :was_important_to, lambda{|user| joins(:importance_indicators).where("importance_indicators.user_id = #{user.id} AND importance_indicators.active = false")}
14
- scope :not_important_to, lambda{|user| with_user_importance(user).where("importance_indicators.record_id IS NULL")}
15
- scope :important_to_user_first, lambda{|user| with_user_importance(user).reorder('importance_indicators.record_id IS NOT NULL DESC')}
10
+ scope :with_user_importance, lambda{|user| joins("LEFT OUTER JOIN importance_indicators ON importance_indicators.record_id = #{quoted_table_name}.id AND importance_indicators.record_type = '#{name}' AND importance_indicators.user_id = #{user.id}")}
11
+
12
+ scope :important_to, lambda{|user| joins(:importance_indicators).where("importance_indicators.user_id = #{user.id} AND importance_indicators.active = true")}
13
+ scope :was_important_to, lambda{|user| joins(:importance_indicators).where("importance_indicators.user_id = #{user.id} AND importance_indicators.active = false")}
14
+ scope :not_important_to, lambda{|user| with_user_importance(user).where("importance_indicators.record_id IS NULL")}
15
+ scope :important_to_user_first, lambda{|user| with_user_importance(user).reorder('importance_indicators.record_id IS NOT NULL DESC')}
16
16
 
17
17
  extend ActsAsImportant::ClassMethods
18
18
  include ActsAsImportant::InstanceMethods
19
19
  end
20
-
20
+
21
21
  # Call this method from the user model
22
22
  def concerned_with_importance
23
23
  has_many :importance_indicators
@@ -35,11 +35,11 @@ module ActsAsImportant
35
35
  for record in records
36
36
  record.cached_importance = importance_indicators[record.id] || false
37
37
  end
38
-
39
- return importance_indicators
38
+
39
+ return importance_indicators
40
40
  end
41
41
  end
42
-
42
+
43
43
  module InstanceMethods
44
44
  attr_accessor :cached_importance
45
45
 
@@ -50,9 +50,9 @@ module ActsAsImportant
50
50
  def important_to!(user)
51
51
  importance_indicators.create(:user_id => user.id) unless important_to?(user)
52
52
  rescue ActiveRecord::RecordNotUnique # Database-level uniqueness constraint failed.
53
- return true
53
+ return true
54
54
  end
55
-
55
+
56
56
  def important_to?(user)
57
57
  if indicator = importance_indicator_for(user)
58
58
  indicator.active?
@@ -75,7 +75,7 @@ module ActsAsImportant
75
75
  cached_importance
76
76
  end
77
77
  end
78
-
78
+
79
79
  def importance_note_for(user)
80
80
  importance_indicator_for(user).try(:note)
81
81
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_important
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicholas Jakobsen
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-29 00:00:00.000000000 Z
12
+ date: 2014-02-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '3.1'
20
+ version: 4.0.0
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: '3.1'
27
+ version: 4.0.0
28
28
  description:
29
29
  email: contact@culturecode.ca
30
30
  executables: []