Sha256: 714554b30e7227e64a11be9b00f4d1378b71accd8823b3ae1dbd370549eb7bc2
Contents?: true
Size: 919 Bytes
Versions: 1
Compression:
Stored size: 919 Bytes
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) instance_eval(&options[:scope]) else options[:scope] end else :global end controller_instance.current_user.roles(options[:scope] || :global).include?(role) end end RoleAuthorization::Rules.define :user do resource = controller_instance.instance_variable_get("@#{options[:resource]}".to_sym) if resource.nil? false else controller_instance.current_user.try(:id) == resource.try(options[:check]) end end RoleAuthorization::Rules.define :custom do unless options[:block].nil? true if options[:block].call(controller_instance) == true else false end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
role_authorization-0.3.3 | lib/role_authorization/rules/defaults.rb |