action-store 0.2.2 → 0.3.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/CHANGELOG.md +23 -0
- data/lib/action_store/mixin.rb +8 -5
- data/lib/action_store/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26301184cdf3a950440f0d0c565943abdc8db2ef
|
4
|
+
data.tar.gz: df943444fc2af10a16eb54a76ea0174035f05258
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3cde2d271a90c35adbf0bb7ec046536e2e2c86349ef71e3d647e46b4c0a16d644eb37e168fb16e1ce488e1e7e78053da05ca5f01e1896b4a0fb1ebabe1b56d25
|
7
|
+
data.tar.gz: ec5998dff944bac6dbd5ebba2717e902eff60dd760013e34ab062f23840d5f3cd8c342880e52b9e445abd9fda0fd55980084fae63c9bc2351cbb8ba48c2490fc
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,26 @@
|
|
1
|
+
0.3.0
|
2
|
+
-----
|
3
|
+
|
4
|
+
- Fix for action_store in Model that not named `User`.
|
5
|
+
- Fix has_many name when `User` model in a namespace.
|
6
|
+
|
7
|
+
For example:
|
8
|
+
|
9
|
+
```rb
|
10
|
+
class Person
|
11
|
+
action_store :like, :post
|
12
|
+
end
|
13
|
+
|
14
|
+
module Blog
|
15
|
+
class User
|
16
|
+
action_store :like, :post
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
@post.like_by_people, @post.like_by_person_actions
|
21
|
+
@blog_user.like_post(@post), @post.like_by_blog_users, @post.like_by_blog_user_actions
|
22
|
+
```
|
23
|
+
|
1
24
|
0.2.2
|
2
25
|
-----
|
3
26
|
|
data/lib/action_store/mixin.rb
CHANGED
@@ -33,8 +33,9 @@ module ActionStore
|
|
33
33
|
|
34
34
|
def action_store(action_type, name, opts = {})
|
35
35
|
opts ||= {}
|
36
|
-
|
37
|
-
|
36
|
+
target_type = name
|
37
|
+
klass_name = opts[:class_name] || name.to_s.classify
|
38
|
+
target_klass = klass_name.constantize
|
38
39
|
action_type = action_type.to_s
|
39
40
|
if opts[:counter_cache] == true
|
40
41
|
# @post.stars_count
|
@@ -50,7 +51,7 @@ module ActionStore
|
|
50
51
|
action_name: name.to_s,
|
51
52
|
action_type: action_type,
|
52
53
|
target_klass: target_klass,
|
53
|
-
target_type:
|
54
|
+
target_type: target_klass.name,
|
54
55
|
counter_cache: opts[:counter_cache],
|
55
56
|
user_counter_cache: opts[:user_counter_cache]
|
56
57
|
}
|
@@ -126,7 +127,7 @@ module ActionStore
|
|
126
127
|
user_klass = self
|
127
128
|
|
128
129
|
# user, person
|
129
|
-
user_name = user_klass.
|
130
|
+
user_name = user_klass.table_name.underscore.singularize
|
130
131
|
|
131
132
|
# like_topic, follow_user
|
132
133
|
full_action_name = [action_type, action_name].join('_')
|
@@ -150,7 +151,9 @@ module ActionStore
|
|
150
151
|
}
|
151
152
|
|
152
153
|
# User has_many :like_topic_actions
|
153
|
-
user_klass.send :has_many, has_many_name, has_many_scope,
|
154
|
+
user_klass.send :has_many, has_many_name, has_many_scope,
|
155
|
+
class_name: 'Action',
|
156
|
+
foreign_key: 'user_id'
|
154
157
|
# User has_many :like_topics
|
155
158
|
user_klass.send :has_many, has_many_through_name,
|
156
159
|
through: has_many_name,
|
data/lib/action_store/version.rb
CHANGED