aserto 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/aserto/errors.rb +1 -0
  4. data/lib/aserto.rb +11 -1
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8367f27ac3bf9072b9b1d09015e555ceb0d33057f91269daa4d67f90ff3afff2
4
- data.tar.gz: f552b23fc37d957b7e8f8b3b75acdb28761a9853e2accc93cc00b5177f1749c4
3
+ metadata.gz: e68ebb38114ba76d726e65f348946433c1ab94a18fcc20a3b41c00d07bf4b738
4
+ data.tar.gz: 9ed57062704dcc6a3b220dcb53140b8c474794b6af887ea2f5bbbc1611b04baf
5
5
  SHA512:
6
- metadata.gz: 496d44c19c75442b90912ed89cc39aa07327570f1dec7eb7941962e0e0ad10e8b3fb82aabae5feb14650141fdbd2d3e2233cbee98c14fc0e513b1fdf18a2bc57
7
- data.tar.gz: c8bc793fbd18940f3f433141d9e8b299e9e879ac30fccbce7eb8e0d6785377960d9946b08b8dd2dee7db0d06efd58eca5850b60cdbcddad8a9d55a556dc676ff
6
+ metadata.gz: '03397de5e0773e962c6503ac01e9f8e312e2ab16d9e2642cbdc10965167e1bbb21500a17cede64fabc16757e3b890abaaaf229154b5059292a3fea5eb950747b'
7
+ data.tar.gz: 91f2df019a74bf1eb58e37580efc70c4479f38eb31a01762fe7fc5c70373444ea5525d8656dfa14a7d8cf789d417789597ff75a0ab54fa4bbd98dc273bb6216c
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
data/lib/aserto/errors.rb CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  module Aserto
4
4
  class Error < StandardError; end
5
+ class InvalidResourceMapping < Error; end
5
6
 
6
7
  class AccessDenied < Error
7
8
  attr_reader :action, :conditions
data/lib/aserto.rb CHANGED
@@ -51,7 +51,17 @@ module Aserto
51
51
  def with_resource_mapper
52
52
  Aserto::ResourceMapper.class_eval do |klass|
53
53
  klass.define_singleton_method(:execute) do |request|
54
- yield(request) if block_given?
54
+ if block_given?
55
+ result = yield(request)
56
+ unless result.is_a?(Hash)
57
+ raise Aserto::InvalidResourceMapping, "block must return a hash, got: #{result.class}"
58
+ end
59
+
60
+ require "google/protobuf/well_known_types"
61
+
62
+ result.transform_keys!(&:to_s)
63
+ Google::Protobuf::Struct.from_hash(result)
64
+ end
55
65
  end
56
66
  end
57
67
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aserto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aserto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-26 00:00:00.000000000 Z
11
+ date: 2022-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aserto-grpc-authz