Module: SuperAuth::Reach
- Defined in:
- lib/super_auth/reach.rb
Class Method Summary collapse
- .normalize(resource_type:, parent: nil) ⇒ Object
-
.parents(reach) ⇒ Object
The column steps alone, for the layer emitting one per parent and for recording what a policy was built from.
Class Method Details
.normalize(resource_type:, parent: nil) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/super_auth/reach.rb', line 35 def normalize(resource_type:, parent: nil) reach = { id: types(resource_type, "resource_type:") } entries(parent).each do |entry| unless entry.is_a?(Hash) && (entry.keys - %i[column resource_type]).empty? raise Error, "parent: must be a Hash {column:, resource_type:} or an Array of them, got #{entry.inspect}" end column = column_name(entry[:column]) if reach.key?(column) raise Error, "parent: column #{column.inspect} is declared twice; list every type it admits under one entry" end reach[column] = types(entry[:resource_type], "parent: #{column} resource_type:") end reach.freeze end |
.parents(reach) ⇒ Object
The column steps alone, for the layer emitting one per parent and for recording what a policy was built from.
52 53 54 |
# File 'lib/super_auth/reach.rb', line 52 def parents(reach) reach.reject { |column, _| column == :id } end |