crewd_policies 0.2.2 → 0.3.0

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: 6527ffcacef669ab324ad83777f7cd17fc1f9247
4
- data.tar.gz: 54e20371399a543275ce840d166b7c023f6d57da
3
+ metadata.gz: da58fbf9df8d461a914137bab938033f4efee6a0
4
+ data.tar.gz: b553dbabc6208daa598cabb5b727e9bfec5080b1
5
5
  SHA512:
6
- metadata.gz: c9615f3137be60929726f364fc737de22aed85b507e0917439f7f468e1987d16b251e9345e0e40aff8d471e3d3148536674e14e69be85cf694a83938bee1f8dd
7
- data.tar.gz: 96234ccddb979b38d50bbe238eff59e0757f38d9a89883584ce0ffec12883ba155d5d0d5af081a5c04a590af4a57fbae7db34e5975e2ae1fafaa611581adc7b7
6
+ metadata.gz: 638f046880f1001e59df48d61dba5300d4fcdaf2a5d8e2c0d3a5d14c832519afd69ec939d2e66e2aafd0fefe808fe1cdfce4c2a742fbb3ca2ca3473133326c0b
7
+ data.tar.gz: 02aa2ac5d8dc3f9aaf3df456a0ed96a75ec37121cecb2713ac67ae2c0b4a6886b3c521a4b6e6caa7bf197c830ff1ea7526453e40b6b51c64285813927ffd4662
@@ -21,9 +21,9 @@ module CrewdPolicies::Model
21
21
  aRole.each {|r| allow(r,aAbilities.dup) }
22
22
  return
23
23
  end
24
- raise "aRole must be a string or a symbol" unless aRole.is_a?(String) or aRole.is_a?(Symbol)
24
+ raise ::StandardExceptions::Http::InternalServerError.new "aRole must be a string or a symbol" unless aRole.is_a?(String) or aRole.is_a?(Symbol)
25
25
  aRole = aRole.to_s
26
- raise "aAbilities must be a Hash" unless aAbilities.is_a? Hash # eg. :write => [:name,:address]
26
+ raise ::StandardExceptions::Http::InternalServerError.new "aAbilities must be a Hash" unless aAbilities.is_a? Hash # eg. :write => [:name,:address]
27
27
 
28
28
  role_rules = (self.roles_rules[aRole] ||= [])
29
29
  conditions = {}
@@ -42,7 +42,7 @@ module CrewdPolicies::Model
42
42
  if fields==true # special "field" value to mean the record or class
43
43
  rule[:allowed] = true
44
44
  else
45
- raise "create, destroy and index must have true as a value, not an array of fields" if a=='create' or a=='destroy' or a=='index'
45
+ raise ::StandardExceptions::Http::InternalServerError.new "create, destroy and index must have true as a value, not an array of fields" if a=='create' or a=='destroy' or a=='index'
46
46
  rule[:fields] = fields
47
47
  end
48
48
  end
@@ -1,5 +1,6 @@
1
1
  require 'active_support/core_ext/class/attribute'
2
2
  require 'active_support/core_ext/string/inflections'
3
+ require 'pundit'
3
4
  require 'standard_exceptions'
4
5
 
5
6
  module CrewdPolicies
@@ -141,7 +142,7 @@ module CrewdPolicies
141
142
  def inner_query_fields(aAbility)
142
143
  internal_server_error! "roles_rules not found on #{record_class.name}, make sure it has \"include CrewdPolicies::Model\"" unless ra = record_class.roles_rules rescue nil
143
144
  unauthorized! "identity not given" if !identity
144
- internal_server_error! "identity must implement has_role?" if !identity.responds_to? :has_role?
145
+ internal_server_error! "identity must implement has_role?" if !identity.respond_to? :has_role?
145
146
 
146
147
  ability = coalesce_field_ability(aAbility)
147
148
 
@@ -209,7 +210,7 @@ module CrewdPolicies
209
210
 
210
211
  # does the identity have this ability on the record/resource at all?
211
212
  def inner_query_ability(aAbility)
212
- raise "aAbility must be a string or a symbol" unless aAbility.is_a?(String) or aAbility.is_a?(Symbol)
213
+ internal_server_error! "aAbility must be a string or a symbol" unless aAbility.is_a?(String) or aAbility.is_a?(Symbol)
213
214
  aAbility = aAbility.to_s
214
215
 
215
216
  case aAbility
@@ -218,7 +219,7 @@ module CrewdPolicies
218
219
  when 'create','destroy','index'
219
220
  inner_query_resource(aAbility)
220
221
  else
221
- raise 'this ability is unknown'
222
+ internal_server_error! 'this ability is unknown'
222
223
  end
223
224
  end
224
225
  end
@@ -1,3 +1,3 @@
1
1
  module CrewdPolicies
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crewd_policies
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gary McGhee