unidom-authorization 0.2 → 1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 858f8c984eb707ee753575de46356fe27455d1dc
4
- data.tar.gz: 1bd878f287b1ad25081637204ef919587de9a8a1
3
+ metadata.gz: c33f00597f81f77f4af640b1cb72e47e736e1c3f
4
+ data.tar.gz: b178379cec884fbce6f3a69e2b34e8438c0537a2
5
5
  SHA512:
6
- metadata.gz: 546fcf647a44bc377faaea9593b7994b6378d801378bf5afbfb632d13066a6948f062086e33e49b4c3c495c4c61b4fe27d192a9b8e202cae74939dab381a5884
7
- data.tar.gz: fc6b336949e154478e30aba6da6a7aae183c61823210e778f4b3a7324f5bfd2d9ef68b8b3a77caa22681ca645befc25a1e5b2d23e6d36cd5aae61afc21243474
6
+ metadata.gz: 5306f671d64ab3f36b7358a11b0769c44d058b5615cd8381ee65ada803552ad102fc9357ec95800a6f985dbbb3d2620cf001376799222b8d20ec904811b8a90e
7
+ data.tar.gz: 38a89f8d22957deb576c3aee72f99106bb3772c337ab076e7eae70051ab8f29fa02ddb16bf82ae4a0a6fc44d4c3e2400a93fd64d9a7d2dddaf5ed460e6bf9850
data/README.md CHANGED
@@ -27,5 +27,5 @@ Unidom::Authorization::Permission.valid_at.alive
27
27
  Unidom::Authorization::Authorizing.valid_at.alive
28
28
 
29
29
  permission = Unidom::Authorization::Permission.valid_at.alive.first
30
- Unidom::Authorization::Authorizing.authorize! permission, user
30
+ Unidom::Authorization::Authorizing.authorize! permission: permission, authorized: user
31
31
  ```
@@ -14,7 +14,11 @@ class Unidom::Authorization::Authorizing < ActiveRecord::Base
14
14
  scope :authorized_is, ->(authorized) { where authorized: authorized }
15
15
  scope :authorized_by, ->(authorizer) { where authorizer: authorizer }
16
16
 
17
- def self.authorize!(permission, authorized, authorizer = nil, opened_at = Time.now)
17
+ def self.authorize!(permission: nil, authorized: nil, authorizer: nil, opened_at: Time.now)
18
+ raise ArgumentError.new('The authorized argument is required.') if authorized.blank?
19
+ raise ArgumentError.new('The opened_at argument is required.' ) if opened_at.blank?
20
+ raise ArgumentError.new('The permission argument is required.') if permission.blank?
21
+
18
22
  attributes = { opened_at: opened_at }
19
23
  if authorizer.present?
20
24
  attributes[:authorizer] = authorizer
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Authorization
3
- VERSION = '0.2'.freeze
3
+ VERSION = '1.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unidom-authorization
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.2'
4
+ version: '1.0'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Topbit Du
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-18 00:00:00.000000000 Z
11
+ date: 2016-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common