invitational 1.3.1 → 1.3.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: fccb799a01e843caccefb56ff690c2864f56fca7
4
- data.tar.gz: f9bdf687a142a029ee04c9fc38cd02c590573a88
3
+ metadata.gz: aa0308853121b61e0485e83fabfe5bec0fcca305
4
+ data.tar.gz: 89208f4dd480f07394e1ed7b6f25c99dc5d055d2
5
5
  SHA512:
6
- metadata.gz: 4ebc2f1a33ded3578e225236bb1d4b62ed035e9dc1daf8e9c0a5f6a14fe50c5f992b82fbef047beccdd5342e2b6ee45828b7c5c334526ab048cad89f90bb336e
7
- data.tar.gz: a3f24a43e239f9f13a456375b5e57de16e4cf6ca35c499b6eb08b819b532a1d16baff23e2112f5d47b829c6006654ba001398d52e51abbc9af55e742b31eb402
6
+ metadata.gz: 299d2c4a4931fc17593d46fdc3aea3bf15e5f8fa76187e2b32ed104b52efe6e47c3ba2bb432f0911b334b3eacef54d9f918016a3026356d6bb7a03521b8d4f1c
7
+ data.tar.gz: 3088c2e22b59d5853a34dd83debfd46fb3b1cb7911d0d29a41a9cfd56270ef47491c72b57507945bfb0b70e59885748e6c563516c12e42e82d34cf0c27784717
data/README.md CHANGED
@@ -114,6 +114,14 @@ License.contract_managers
114
114
  License.bookkeepers
115
115
  ```
116
116
 
117
+ Similarly, the identity model is given scopes for each role:
118
+
119
+ ```
120
+ User.uberadmins # returns users who are uberadmins
121
+ User.contract_managers # returns users with the contract_manager system role
122
+ User.bookkeepers # returns users with the bookkeepers system role
123
+ ```
124
+
117
125
  #Usage
118
126
  ##Creating Invitations
119
127
  To create an entity invitation to a given model:
@@ -42,7 +42,7 @@ module Invitational
42
42
  scope :pending, lambda { where('user_id IS NULL') }
43
43
  scope :claimed, lambda { where('user_id IS NOT NULL') }
44
44
 
45
- @system_roles = Array.new
45
+ @system_roles = [:uberadmin]
46
46
 
47
47
  def self.system_roles
48
48
  @system_roles
@@ -4,6 +4,10 @@ module Invitational
4
4
 
5
5
  included do
6
6
  has_many :invitations, dependent: :destroy
7
+
8
+ Invitation.system_roles.each do |role_name|
9
+ scope role_name.to_s.pluralize, -> { joins(:invitations).merge Invitation.for_system_role(role_name) }
10
+ end
7
11
  end
8
12
 
9
13
  module ClassMethods
@@ -1,6 +1,7 @@
1
1
  module Invitational
2
2
  module CanCan
3
3
  module Ability
4
+ include ::CanCan::Ability
4
5
 
5
6
  def can(action = nil, subject = nil, conditions = nil, &block)
6
7
  if conditions && conditions.has_key?(:roles)
@@ -10,7 +11,7 @@ module Invitational
10
11
  block ||= setup_role_based_block_for roles, subject, action, false
11
12
  end
12
13
 
13
- rules << ::CanCan::Rule.new(true, action, subject, conditions, block)
14
+ add_rule ::CanCan::Rule.new(true, action, subject, conditions, block)
14
15
  end
15
16
 
16
17
  def cannot(action = nil, subject = nil, conditions = nil, &block)
@@ -21,7 +22,7 @@ module Invitational
21
22
  block ||= setup_role_based_block_for roles, subject, action, true
22
23
  end
23
24
 
24
- rules << ::CanCan::Rule.new(false, action, subject, conditions, block)
25
+ add_rule ::CanCan::Rule.new(false, action, subject, conditions, block)
25
26
  end
26
27
 
27
28
  def setup_role_based_block_for roles, subject, action, role_specific
@@ -1,3 +1,3 @@
1
1
  module Invitational
2
- VERSION = "1.3.1"
2
+ VERSION = "1.3.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: invitational
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Goerlich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-06 00:00:00.000000000 Z
11
+ date: 2016-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -175,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
175
  version: '0'
176
176
  requirements: []
177
177
  rubyforge_project:
178
- rubygems_version: 2.2.0
178
+ rubygems_version: 2.4.8
179
179
  signing_key:
180
180
  specification_version: 4
181
181
  summary: Solution that eliminates the tight coupling between user identity/authentication