aegis 1.1.5 → 1.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -94,7 +94,7 @@ You can define a default role for a model by saying
94
94
  has_role :default => :admin
95
95
  end
96
96
  All this will do, is initialize the +role_name+ with the given default when
97
- +User.new+ is called.
97
+ <tt>User.new</tt> is called.
98
98
 
99
99
  The roles and permissions themselves are defined in a class inheriting from
100
100
  <b>Aegis::Permissions</b>. To define roles you create a model <tt>permissions.rb</tt>
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.5
1
+ 1.1.6
data/aegis.gemspec CHANGED
@@ -1,8 +1,11 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
1
4
  # -*- encoding: utf-8 -*-
2
5
 
3
6
  Gem::Specification.new do |s|
4
7
  s.name = %q{aegis}
5
- s.version = "1.1.5"
8
+ s.version = "1.1.6"
6
9
 
7
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
11
  s.authors = ["Henning Koch"]
@@ -70,7 +70,7 @@ module Aegis
70
70
  end
71
71
 
72
72
  private
73
-
73
+
74
74
  # Delegate may_...? and may_...! methods to the user's role.
75
75
  def method_missing_with_aegis_permissions(symb, *args)
76
76
  method_name = symb.to_s
@@ -85,6 +85,16 @@ module Aegis
85
85
 
86
86
  alias_method_chain :method_missing, :aegis_permissions
87
87
 
88
+ def respond_to_with_aegis_permissions?(symb, include_private = false)
89
+ if symb.to_s =~ /^may_(.+?)[\!\?]$/
90
+ true
91
+ else
92
+ respond_to_without_aegis_permissions?(symb, include_private)
93
+ end
94
+ end
95
+
96
+ alias_method_chain :respond_to?, :aegis_permissions
97
+
88
98
  def set_default_aegis_role_name
89
99
  if new_record?
90
100
  self.aegis_role_name ||= self.class.aegis_default_role_name
@@ -39,6 +39,16 @@ class HasRoleTest < ActiveSupport::TestCase
39
39
  end
40
40
  end
41
41
 
42
+ should "know that they respond to permission methods" do
43
+ assert @guest.respond_to?(:may_foo?)
44
+ assert @guest.respond_to?(:may_foo!)
45
+ end
46
+
47
+ should "retain the usual respond_to behaviour for non-permission methods" do
48
+ assert !@guest.respond_to?(:nonexisting_method)
49
+ assert @guest.respond_to?(:to_s)
50
+ end
51
+
42
52
  end
43
53
 
44
54
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aegis
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henning Koch