Module: JwtBouncer::Permissions
- Defined in:
- lib/jwt_bouncer/permissions.rb
Class Method Summary collapse
- .compress(permissions) ⇒ Object
- .decompress(permissions) ⇒ Object
- .destructure(permissions) ⇒ Object
Class Method Details
.compress(permissions) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/jwt_bouncer/permissions.rb', line 8 def self.compress() stream = StringIO.new zip = Zlib::GzipWriter.new(stream) begin zip.write(.to_json) ensure zip.close end Base64.encode64(stream.string) end |
.decompress(permissions) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/jwt_bouncer/permissions.rb', line 20 def self.decompress() unzipped_stream = StringIO.new StringIO.open(Base64.decode64()) do |stream| unzip = Zlib::GzipReader.new(stream) begin unzipped_stream.write(unzip.read) ensure unzip.close end end JSON.parse(unzipped_stream.string) end |
.destructure(permissions) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/jwt_bouncer/permissions.rb', line 34 def self.destructure() = [] .each do |service, resources| resources.each do |resource, | .each do || << [service, resource, ].join('_') end end end end |