Sha256: 3ad04821a3308999ae2d54c0a39fd2e7e00b921d824420e011346138714e05a4

Contents?: true

Size: 507 Bytes

Versions: 41

Compression:

Stored size: 507 Bytes

Contents

module Rasti
  class App
    class Permission < String

      SEPARATOR = '.'

      def initialize(*args)
        super Array(args).flatten.map(&:to_s).join(SEPARATOR)
      end

      def include?(permission)
        other = Permission.new permission
        sections.count <= other.sections.count && self == other.sections.take(sections.count).join(SEPARATOR)
      end

      def sections
        split SEPARATOR
      end

      def last_section
        sections.last
      end
      
    end
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
rasti-app-2.2.2 lib/rasti/app/permission.rb
rasti-app-2.2.1 lib/rasti/app/permission.rb
rasti-app-2.2.0 lib/rasti/app/permission.rb
rasti-app-2.1.1 lib/rasti/app/permission.rb
rasti-app-2.1.0 lib/rasti/app/permission.rb
rasti-app-2.0.0 lib/rasti/app/permission.rb
rasti-app-1.1.0 lib/rasti/app/permission.rb
rasti-app-1.0.0 lib/rasti/app/permission.rb
rasti-app-0.1.2 lib/rasti/app/permission.rb
rasti-app-0.1.1 lib/rasti/app/permission.rb
rasti-app-0.1.0 lib/rasti/app/permission.rb
rasti-app-0.0.10 lib/rasti/app/permission.rb
rasti-app-0.0.9 lib/rasti/app/permission.rb
rasti-app-0.0.8 lib/rasti/app/permission.rb
rasti-app-0.0.7 lib/rasti/app/permission.rb
rasti-app-0.0.6 lib/rasti/app/permission.rb
rasti-app-0.0.5 lib/rasti/app/permission.rb
rasti-app-0.0.4 lib/rasti/app/permission.rb
rasti-app-0.0.3 lib/rasti/app/permission.rb
rasti-app-0.0.2 lib/rasti/app/permission.rb