Permalink
Browse files

Move common Spree.user_class role decorations into core

As per BDQ's comment here: #1512 (comment)
  • Loading branch information...
1 parent 73ded00 commit 04b84e3c3862fb65e2f25f583e84ecba8f506ab3 @radar radar committed May 23, 2012
@@ -1,7 +1,5 @@
if Spree.user_class
Spree.user_class.class_eval do
- has_and_belongs_to_many :roles, :join_table => 'spree_roles_users'
-
def generate_api_key!
self.api_key = SecureRandom.hex(24)
save!
@@ -11,10 +9,5 @@ def clear_api_key!
self.api_key = nil
save!
end
-
- # has_spree_role? simply needs to return true or false whether a user has a role or not.
- def has_spree_role?(role_in_question)
- roles.any? { |role| role.name == role_in_question.to_s }
- end
end
end
@@ -0,0 +1,11 @@
+if Spree.user_class
+ Spree.user_class.class_eval do
+ has_and_belongs_to_many :roles, :join_table => 'spree_roles_users'
+
+ # has_spree_role? simply needs to return true or false whether a user has a role or not.
+ def has_spree_role?(role_in_question)
+ roles.any? { |role| role.name == role_in_question.to_s }
+ end
+ end
+end
+
@@ -1,5 +0,0 @@
-if Spree.user_class
- Spree.user_class.class_eval do
- has_and_belongs_to_many :roles, :join_table => 'spree_roles_users'
- end
-end
@@ -1,5 +0,0 @@
-if Spree.user_class
- Spree.user_class.class_eval do
- has_and_belongs_to_many :roles, :join_table => 'spree_roles_users'
- end
-end

0 comments on commit 04b84e3

Please sign in to comment.