Skip to content
Browse files

Merge pull request #15 from james2m/master

update mask_for, fix rdoc deprecation and remove Gemfile.lock.
  • Loading branch information...
2 parents 565e919 + 9d766b0 commit 16240202f977e6e78e9ddad0bc9a58f2f32a5614 @martinrehfeld martinrehfeld committed Mar 26, 2012
Showing with 7 additions and 33 deletions.
  1. +1 −0 .gitignore
  2. +1 −0 Gemfile
  3. +0 −29 Gemfile.lock
  4. +2 −2 Rakefile
  5. +3 −2 lib/role_model/class_methods.rb
View
1 .gitignore
@@ -23,3 +23,4 @@ pkg
## PROJECT::SPECIFIC
.rvmrc
+Gemfile.lock
View
1 Gemfile
@@ -3,5 +3,6 @@ source 'http://rubygems.org'
group :development do
gem 'jeweler', '>=1.5.2'
gem 'rspec', '~> 2'
+ gem 'rdoc', '>=2.4.2'
gem 'autotest'
end
View
29 Gemfile.lock
@@ -1,29 +0,0 @@
-GEM
- remote: http://rubygems.org/
- specs:
- ZenTest (4.5.0)
- autotest (4.4.6)
- ZenTest (>= 4.4.1)
- diff-lcs (1.1.2)
- git (1.2.5)
- jeweler (1.5.2)
- bundler (~> 1.0.0)
- git (>= 1.2.5)
- rake
- rake (0.8.7)
- rspec (2.5.0)
- rspec-core (~> 2.5.0)
- rspec-expectations (~> 2.5.0)
- rspec-mocks (~> 2.5.0)
- rspec-core (2.5.1)
- rspec-expectations (2.5.0)
- diff-lcs (~> 1.1.2)
- rspec-mocks (2.5.0)
-
-PLATFORMS
- ruby
-
-DEPENDENCIES
- autotest
- jeweler (>= 1.5.2)
- rspec (~> 2)
View
4 Rakefile
@@ -40,8 +40,8 @@ end
task :default => :spec
-require 'rake/rdoctask'
-Rake::RDocTask.new do |rdoc|
+require 'rdoc/task'
+RDoc::Task.new do |rdoc|
version = File.exist?('VERSION') ? File.read('VERSION') : ""
rdoc.rdoc_dir = 'rdoc'
View
5 lib/role_model/class_methods.rb
@@ -19,10 +19,11 @@ def roles_attribute=(name)
end
def mask_for(*roles)
- sanitized_roles = roles.map { |role| role.is_a?(Set) ? role.to_a : role }.flatten.map(&:to_sym)
+ sanitized_roles = roles.map { |role| Array(role) }.flatten.map(&:to_sym)
+
(valid_roles & sanitized_roles).inject(0) { |sum, role| sum + 2**valid_roles.index(role) }
end
-
+
protected
# :call-seq:

0 comments on commit 1624020

Please sign in to comment.
Something went wrong with that request. Please try again.