Sha256: d1b036bd84bbecc3eecca64a0c85b852746af6b7f37956888cc2aec87a2c1fda

Contents?: true

Size: 610 Bytes

Versions: 6

Compression:

Stored size: 610 Bytes

Contents

RoleAuthorization::Rules.define :all do
  true
end

RoleAuthorization::Rules.define :role do
  controller_instance.current_user.roles(options[:scope] || :global).include?(options[:role])
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

6 entries across 6 versions & 1 rubygems

Version Path
role_authorization-0.2.5 lib/role_authorization/rules/defaults.rb
role_authorization-0.2.4 lib/role_authorization/rules/defaults.rb
role_authorization-0.2.3 lib/role_authorization/rules/defaults.rb
role_authorization-0.2.2 lib/role_authorization/rules/defaults.rb
role_authorization-0.2.1 lib/role_authorization/rules/defaults.rb
role_authorization-0.2.0 lib/role_authorization/rules/defaults.rb