Skip to content

Commit

Permalink
Optimize the roles_name memory allocation using pluck
Browse files Browse the repository at this point in the history
Avoid to instantiate models and just use the the returned values as they are
  • Loading branch information
Gustavo Bazan authored and EppO committed Feb 26, 2019
1 parent 35afa2e commit e1ac260
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rolify/role.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def remove_role(role_name, resource = nil)
deprecate :has_no_role, :remove_role

def roles_name
self.roles.select(:name).map { |r| r.name }
self.roles.pluck(:name)
end

def method_missing(method, *args, &block)
Expand Down

0 comments on commit e1ac260

Please sign in to comment.