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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c6feb8f1b2ac1d6ff4f3431e798270b81a417384
4
- data.tar.gz: d2462e9c3e33a78ebbff6ac81a1d7db24d2bc9a1
3
+ metadata.gz: dd234fd73236bef5cd67d146410569e1c7158dfc
4
+ data.tar.gz: 84cb6b0fa34d985afa568ac62db32b049444baf4
5
5
  SHA512:
6
- metadata.gz: 8ff2519a6720381adbab46b1e38b3cc6300c17f1aa28e8412892ca6c28d76a3b4b025a762ceeefb39957e956bb9d92e0e970c3096bf666834d06dd12a52e3a05
7
- data.tar.gz: 881695e000bce52d937db5928e817d2c2b3c59b9a878d43d5b677c9cf7da9bd9762f1d7b0f7e4d1598aac81bccb208a3f90745761c0d4c8b90d618c94c134d48
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 role_hash;
13
- to_hash;
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
@@ -1,3 +1,3 @@
1
1
  module TheRoleApi
2
- VERSION = "3.0.1"
2
+ VERSION = "3.0.2"
3
3
  end
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.1
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-03 00:00:00.000000000 Z
11
+ date: 2015-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json