Sha256: 790fc14efd00b40dc05f34ea77bb63425efb1945e283aa8b73d28befc67c94c4

Contents?: true

Size: 1.63 KB

Versions: 9

Compression:

Stored size: 1.63 KB

Contents

module GroupDocs
  module Api
    module Helpers
      module AccessRights

        include Api::Helpers::ByteFlag
        #Changed in release 1.5.9
        ACCESS_RIGHTS = {
          :view     => 1,
          :annotate => 2,
          :download => 4,
          :export   => 8,
          :all => 31
        }

        private

        #
        # Converts shared link access rights array to byte flag.
        #
        # @param [Array<String, Symbol>] rights
        # @return [Integer]
        # @raise [ArgumentError] if rights is not an array
        # @raise [ArgumentError] if right is unknown
        # @api private
        #
        def convert_access_rights_to_byte(rights)
          rights.is_a?(Array) or raise ArgumentError, "Rights should be an array, received: #{rights.inspect}"
          rights = rights.map(&:to_sym)

          possible_rights = ACCESS_RIGHTS.map { |hash| hash.first }
          rights.each do |right|
            possible_rights.include?(right) or raise ArgumentError, "Unknown access right: #{rights.inspect}"
          end

          byte_from_array(rights, ACCESS_RIGHTS)
        end

        #
        # Converts byte flag to shared link access rights array.
        #
        # @param [Integer] rights
        # @return [Array<Symbol>]
        # @raise [ArgumentError] if rights is not integer
        # @api private
        #
        def convert_byte_to_access_rights(rights)
          rights.is_a?(Integer) or raise ArgumentError, "Rights should be an integer, received: #{rights.inspect}"
          array_from_byte(rights, ACCESS_RIGHTS)
        end

      end # AccessRights
    end # Helpers
  end # Api
end # GroupDocs

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
groupdocs-2.2.0 lib/groupdocs/api/helpers/access_rights_helper.rb
groupdocs-2.1.0 lib/groupdocs/api/helpers/access_rights_helper.rb
groupdocs-2.0.0 lib/groupdocs/api/helpers/access_rights_helper.rb
groupdocs-1.9.0 lib/groupdocs/api/helpers/access_rights_helper.rb
groupdocs-1.8.1 lib/groupdocs/api/helpers/access_rights_helper.rb
groupdocs-1.8.0 lib/groupdocs/api/helpers/access_rights_helper.rb
groupdocs-1.7.0 lib/groupdocs/api/helpers/access_rights_helper.rb
groupdocs-1.6.0 lib/groupdocs/api/helpers/access_rights_helper.rb
groupdocs-1.5.9 lib/groupdocs/api/helpers/access_rights_helper.rb