the_role_api 3.0.1 → 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/concerns/the_role/api/role.rb +18 -15
- data/app/models/concerns/the_role/api/user.rb +6 -4
- data/gem_version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd234fd73236bef5cd67d146410569e1c7158dfc
|
4
|
+
data.tar.gz: 84cb6b0fa34d985afa568ac62db32b049444baf4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e6032dcecb639c129fe9227df86ee4a037c96a48bbf1e153878b0430582a4c3f01584f78944747096099f33729e37f0ae260e8541ed63dc17e8cfd0c7040310
|
7
|
+
data.tar.gz: 198c3d218bfc673a0fe578c388fff422fdc2737c5252e89a1126d1d6c0d2ae3ad4732d19cfb8c2721e90d193296f0dc518b149f2a2be74bb3a72f41d8aa0378e
|
@@ -5,13 +5,29 @@ module TheRole
|
|
5
5
|
|
6
6
|
include TheRole::Api::BaseMethods
|
7
7
|
|
8
|
+
# HELPERS
|
9
|
+
|
10
|
+
# version for `Role` model
|
11
|
+
def role_hash
|
12
|
+
to_hash
|
13
|
+
end
|
14
|
+
|
8
15
|
def the_role= val
|
9
16
|
self[:the_role] = _jsonable val
|
10
17
|
end
|
11
18
|
|
12
|
-
def
|
13
|
-
|
19
|
+
def _jsonable val
|
20
|
+
val.is_a?(Hash) ? val.to_json : val.to_s
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_hash
|
24
|
+
begin JSON.load(the_role) rescue {} end
|
25
|
+
end
|
26
|
+
|
27
|
+
def to_json
|
28
|
+
the_role
|
14
29
|
end
|
30
|
+
# ~ HELPERS
|
15
31
|
|
16
32
|
alias_method :has?, :has_role?
|
17
33
|
alias_method :any?, :any_role?
|
@@ -54,9 +70,6 @@ module TheRole
|
|
54
70
|
end
|
55
71
|
|
56
72
|
# C
|
57
|
-
def _jsonable val
|
58
|
-
val.is_a?(Hash) ? val.to_json : val.to_s
|
59
|
-
end
|
60
73
|
|
61
74
|
def create_section section_name = nil
|
62
75
|
return false unless section_name
|
@@ -85,16 +98,6 @@ module TheRole
|
|
85
98
|
update_attribute(:the_role, _jsonable(role))
|
86
99
|
end
|
87
100
|
|
88
|
-
# R
|
89
|
-
|
90
|
-
def to_hash
|
91
|
-
begin JSON.load(the_role) rescue {} end
|
92
|
-
end
|
93
|
-
|
94
|
-
def to_json
|
95
|
-
the_role
|
96
|
-
end
|
97
|
-
|
98
101
|
# U
|
99
102
|
|
100
103
|
# source_hash will be reset to false
|
@@ -5,6 +5,12 @@ module TheRole
|
|
5
5
|
|
6
6
|
include TheRole::Api::BaseMethods
|
7
7
|
|
8
|
+
# HELPERS
|
9
|
+
# version for `User` model
|
10
|
+
def role_hash
|
11
|
+
@role_hash ||= role.try(:to_hash) || {}
|
12
|
+
end
|
13
|
+
|
8
14
|
included do
|
9
15
|
belongs_to :role
|
10
16
|
before_validation :set_default_role, on: :create
|
@@ -17,10 +23,6 @@ module TheRole
|
|
17
23
|
end
|
18
24
|
end
|
19
25
|
|
20
|
-
def role_hash;
|
21
|
-
@role_hash ||= role.try(:to_hash) || {}
|
22
|
-
end
|
23
|
-
|
24
26
|
# FALSE if object is nil
|
25
27
|
# If object is a USER - check for youself
|
26
28
|
# Check for owner field - :user_id
|
data/gem_version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: the_role_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilya N. Zykin [the-teacher]
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|