Sha256: 2c81aaf78e89649e4a4a93efff5e8cc601ed97d0ed70bb87511ce6d73f24d190

Contents?: true

Size: 724 Bytes

Versions: 22

Compression:

Stored size: 724 Bytes

Contents

# Public: include this module to make the resource authorizable in Garage::RestfulActions
#
# Examples
#
#   class Post
#     include Garage::Authorizable
#     def build_permissions(perms, other); end
#     def self.build_permissions(perms, other, target); end
#   end
module Garage
  module Authorizable
    def build_permissions(perms, subject)
      raise NotImplementedError, "#{self.class}#build_permissions must be implemented"
    end

    def effective_permissions(subject)
      Garage::Permissions.new(subject, resource_class).tap do |perms|
        build_permissions(perms, subject)
      end
    end

    def authorize!(subject, action)
      effective_permissions(subject).authorize!(action)
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
the_garage-2.8.2 lib/garage/authorizable.rb
the_garage-2.8.1 lib/garage/authorizable.rb
the_garage-2.8.0 lib/garage/authorizable.rb
the_garage-2.7.0 lib/garage/authorizable.rb
the_garage-2.6.1 lib/garage/authorizable.rb
the_garage-2.6.0 lib/garage/authorizable.rb
the_garage-2.5.0 lib/garage/authorizable.rb
the_garage-2.4.4 lib/garage/authorizable.rb
the_garage-2.4.3 lib/garage/authorizable.rb
the_garage-2.4.2 lib/garage/authorizable.rb
the_garage-2.4.1 lib/garage/authorizable.rb
the_garage-2.4.0 lib/garage/authorizable.rb
the_garage-2.3.3 lib/garage/authorizable.rb
the_garage-2.3.2 lib/garage/authorizable.rb
the_garage-2.3.1 lib/garage/authorizable.rb
the_garage-2.3.0 lib/garage/authorizable.rb
the_garage-2.2.0 lib/garage/authorizable.rb
the_garage-2.1.0 lib/garage/authorizable.rb
the_garage-2.0.3 lib/garage/authorizable.rb
the_garage-2.0.2 lib/garage/authorizable.rb