Sha256: 8d2fe0be11aa1cbb00fffb9d94660493d7a2fa4e9bdd113bd216754029020351
Contents?: true
Size: 1.19 KB
Versions: 22
Compression:
Stored size: 1.19 KB
Contents
RoleAuthorization::Rules.define :all do true end RoleAuthorization::Rules.define :role do if controller_instance.current_user.blank? false else scope = if options[:scope] if options[:scope].is_a?(Proc) controller_instance.instance_eval(&options[:scope]) else options[:scope] end else :global end controller_instance.current_user.roles(scope).include?(role) end end RoleAuthorization::Rules.define :user do if controller_instance.current_user.blank? false else if options[:resource] check_method = options[:check] || :id resource_instances = controller_instance.instance_eval(&options[:resource]) resource_instances = [resource_instances] unless resource_instances.is_a?(Array) resource_instances.map do |resource_instance| controller_instance.current_user.id == resource_instance.try(check_method) end.include?(true) else false end end end RoleAuthorization::Rules.define :custom do unless options[:block].nil? true if controller_instance.instance_eval(&options[:block]) == true else false end end
Version data entries
22 entries across 22 versions & 1 rubygems