Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Further simplified mask_for and fixed some deprecation. #1

Closed
wants to merge 3 commits into from

2 participants

@james2m
Owner

Hi Martin,

I've further simplified mask_for, fixed some rdoc deprecation warnings and remove the Gemfile.lock as it's good practice to do so http://yehudakatz.com/2010/12/16/clarifying-the-roles-of-the-gemspec-and-gemfile/.

J.

@martinrehfeld

Hi James,

I just stumbled upon this pull request and would definitely like to merge it in -- for some reason though it is only visible in your fork and not as a pull req listed on my original repo. Maybe you have an idea on how to fix this; otherwise I can also pull your commits manually or through the Github fork queue.

Cheers,
Martin

@james2m
Owner

Hi Martin,

I think it's because I selected the range of commits I wanted to pull and there is no common ancestor. I'll update my fork from your repo, re-apply these and follow up with a new pull request.

Cheers,
James

@james2m
Owner

Going to close this pull request and re-raise.

J.

@james2m james2m closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
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:
Something went wrong with that request. Please try again.