Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Mrjaco12/rolify
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrjaco12 committed Jun 15, 2020
2 parents 1988e8e + 567b694 commit 22d1ab3
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 13 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ after_success:
- bundle exec codeclimate-test-reporter

rvm:
- 2.7.0
- 2.6.3
- 2.5.5
- 2.4.6
Expand Down
2 changes: 2 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
appraise 'mongoid-5' do
gem "mongoid", "~> 5"
gem "bson_ext", "1.5.1"
gem 'bigdecimal', '1.4.2'
end

appraise 'mongoid-6' do
Expand All @@ -17,6 +18,7 @@ end
appraise 'activerecord-4' do
gem "sqlite3", "~> 1.3.6"
gem "activerecord", "~> 4.2.11", :require => "active_record"
gem 'bigdecimal', '1.4.2'
end

appraise 'activerecord-5' do
Expand Down
26 changes: 18 additions & 8 deletions CHANGELOG.rdoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
= 5.3.0 (June 1, 2020)

5.3.0 will be the last version to support Ruby < 2.5 and Rails < 5.2. Support for these will be dropped in the next major release.

* Fix deprecation warning in Ruby 2.7
* Add Rails 6 support to migration generator
* Significant ActiveRecord performance improvements to <tt>add_role</tt> and <tt>without_role</tt>
* Mongoid fix and performance improvement and to <tt>roles_name</tt>
* Make it safe to call <tt>Thing.with_role(:admin, user)</tt> with new record

= 5.2.0 (Dec 14, 2017)
* Fix regression in generator around belongs_to options compatibility
* Update version of database_cleaner
Expand Down Expand Up @@ -126,7 +136,7 @@
* fixed a backward incompatible change introduced in Rails 3.2 release (<tt>find_or_create_by_* generated methods</tt>)

= 2.2 (Jan 18, 2012)
* fixed a bug in the initializer file regarding dynamic shortcuts
* fixed a bug in the initializer file regarding dynamic shortcuts

= 2.1 (Nov 30, 2011)
* added syntactic sugar: <tt>grant</tt> and <tt>revoke</tt> are aliases for <tt>has_role</tt> and <tt>has_no_role</tt>
Expand Down Expand Up @@ -167,8 +177,8 @@

= 1.0 (Aug 25, 2011)
* added a new parameter to disable dynamic shortcut methods due to potential incompatibility with other gems using method_missing with the same pattern
* add <tt>Rolify.dynamic_shortcuts = false</tt> in the initializer file or
* use the generator command with a third parameter:
* add <tt>Rolify.dynamic_shortcuts = false</tt> in the initializer file or
* use the generator command with a third parameter:
* <tt>rails g rolify:role Role User false</tt>
* removed the railtie as it created more problems than it solved
* code refactoring to do some speed improvements and code clean up
Expand All @@ -177,16 +187,16 @@
* rolify is now on travis-ci to monitor build status

= 0.7 (June 20, 2011)
* added a method_missing to catch newly created role outside the current ruby process (i.e. dynamic shortcut methods are not defined within this process)
* dynamic shortcut is created on the fly in the method_missing to avoid extra method_missing for the same dynamic shortcut
* check if the role actually exists in the database before defining the new method
* added a method_missing to catch newly created role outside the current ruby process (i.e. dynamic shortcut methods are not defined within this process)
* dynamic shortcut is created on the fly in the method_missing to avoid extra method_missing for the same dynamic shortcut
* check if the role actually exists in the database before defining the new method
* first call is slower due to method_missing but next calls are fast
* avoid strange bugs when spawning many ruby processes as the dynamic shortcut methods were only defined in the process that used the <tt>has_role</tt> command

= 0.6 (June 19, 2011)
* custom User and Role class names support
* can now use other class names for Role and User classes
* fixed generators and templates
* fixed generators and templates
* join table is explicitly set to avoid alphabetical order issue
* created a new railtie to load the dynamic shortcuts at startup

Expand All @@ -208,7 +218,7 @@
* Trying to remove a role scoped to a resource whereas the user has a global role won't remove it

= v0.3 (June 06, 2011)
* multiple roles check:
* multiple roles check:
* <tt>has_all_roles?</tt> returns true if the user has ALL the roles in arguments
* <tt>has_any_role?</tt> returns true if the user has ANY the roles in arguments

Expand Down
1 change: 1 addition & 0 deletions gemfiles/activerecord_4.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ source "https://rubygems.org"

gem "sqlite3", "~> 1.3.6"
gem "activerecord", "~> 4.2.11", require: "active_record"
gem "bigdecimal", "1.4.2"

group :test do
gem "appraisal"
Expand Down
1 change: 1 addition & 0 deletions gemfiles/mongoid_5.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ source "https://rubygems.org"

gem "mongoid", "~> 5"
gem "bson_ext", "1.5.1"
gem "bigdecimal", "1.4.2"

group :test do
gem "appraisal"
Expand Down
4 changes: 2 additions & 2 deletions lib/rolify.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def rolify(options = {})
rolify_options.merge!({ :join_table => self.role_join_table_name }) if Rolify.orm == "active_record"
rolify_options.merge!(options.reject{ |k,v| ![ :before_add, :after_add, :before_remove, :after_remove, :inverse_of ].include? k.to_sym })

has_and_belongs_to_many :roles, rolify_options
has_and_belongs_to_many :roles, **rolify_options

self.adapter = Rolify::Adapter::Base.create("role_adapter", self.role_cname, self.name)

Expand All @@ -48,7 +48,7 @@ def resourcify(association_name = :roles, options = {})
self.role_cname = options[:role_cname]
self.role_table_name = self.role_cname.tableize.gsub(/\//, "_")

has_many association_name, resourcify_options
has_many association_name, **resourcify_options

self.resource_adapter = Rolify::Adapter::Base.create("resource_adapter", self.role_cname, self.name)
@@resource_types << self.name
Expand Down
2 changes: 1 addition & 1 deletion lib/rolify/adapters/active_record/role_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def where_strict(relation, args)

conditions = if args[:resource].is_a?(Class)
{:resource_type => args[:resource].to_s, :resource_id => nil }
elsif arg[:resource].present?
elsif args[:resource].present?
{:resource_type => args[:resource].class.name, :resource_id => args[:resource].id}
else
{}
Expand Down
2 changes: 1 addition & 1 deletion lib/rolify/adapters/mongoid/role_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def where_strict(relation, args)

conditions = if args[:resource].is_a?(Class)
{:resource_type => args[:resource].to_s, :resource_id => nil }
elsif arg[:resource].present?
elsif args[:resource].present?
{:resource_type => args[:resource].class.name, :resource_id => args[:resource].id}
else
{}
Expand Down
2 changes: 1 addition & 1 deletion lib/rolify/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Rolify
VERSION = "6.0.0"
VERSION = "5.3.0"
end

0 comments on commit 22d1ab3

Please sign in to comment.