acts_as_important 0.1.1 → 0.2.0
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 +4 -4
- data/lib/acts_as_important/acts_as_important.rb +15 -15
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3295e8893c72bc3dc31bbe3b0703c001194edcf6
|
4
|
+
data.tar.gz: 67c0fecfa9d710db5c4d80478b3fbdd8d1cae6be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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,
|
11
|
-
|
12
|
-
scope :important_to,
|
13
|
-
scope :was_important_to,
|
14
|
-
scope :not_important_to,
|
15
|
-
scope :important_to_user_first,
|
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.
|
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-
|
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:
|
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:
|
27
|
+
version: 4.0.0
|
28
28
|
description:
|
29
29
|
email: contact@culturecode.ca
|
30
30
|
executables: []
|