easy_roles 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/easy_roles.gemspec +2 -2
- data/lib/easy_roles.rb +4 -7
- metadata +2 -2
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'echoe'
|
4
4
|
|
5
|
-
Echoe.new('easy_roles', '0.1.
|
5
|
+
Echoe.new('easy_roles', '0.1.2') do |p|
|
6
6
|
p.description = "Easy role authorization in rails"
|
7
7
|
p.url = "http://github.com/platform45/easy_roles"
|
8
8
|
p.author = "Platform45"
|
data/easy_roles.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{easy_roles}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.2"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Platform45"]
|
9
|
-
s.date = %q{2009-10-
|
9
|
+
s.date = %q{2009-10-12}
|
10
10
|
s.description = %q{Easy role authorization in rails}
|
11
11
|
s.email = %q{ryan@platform45.com}
|
12
12
|
s.extra_rdoc_files = ["README.rdoc", "lib/easy_roles.rb"]
|
data/lib/easy_roles.rb
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
module EasyRoles
|
2
2
|
def self.included(base)
|
3
3
|
base.extend ClassMethods
|
4
|
-
|
5
|
-
base.send :alias_method_chain, :method_missing, :roles
|
6
4
|
end
|
7
5
|
|
8
6
|
module ClassMethods
|
9
7
|
def easy_roles(name)
|
10
8
|
serialize name.to_sym, Array
|
11
9
|
before_validation_on_create :make_default_roles
|
10
|
+
self.superclass.send :alias_method_chain, :method_missing, :roles
|
12
11
|
|
13
12
|
class_eval <<-EOC
|
14
13
|
def has_role?(role)
|
@@ -39,11 +38,9 @@ module EasyRoles
|
|
39
38
|
def method_missing_with_roles(method_id, *args, &block)
|
40
39
|
match = method_id.to_s.match(/^is_(\w+)[?]$/)
|
41
40
|
if match && respond_to?('has_role?')
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
end
|
46
|
-
EOC
|
41
|
+
self.class.send(:define_method, "is_#{match[1]}?") do
|
42
|
+
send :has_role?, "#{match[1]}"
|
43
|
+
end
|
47
44
|
send "is_#{match[1]}?"
|
48
45
|
else
|
49
46
|
method_missing_without_roles(method_id, *args, &block)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy_roles
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Platform45
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-10-
|
12
|
+
date: 2009-10-12 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|