Permalink
Browse files

Add checks for Spree.user_class to api, dash and promo user decorators

  • Loading branch information...
1 parent b7cf532 commit e15009ed161fb2fcf42cfe05c4fd7ac85a8c8a63 @radar radar committed May 10, 2012
@@ -1,18 +1,20 @@
-Spree.user_class.class_eval do
- has_and_belongs_to_many :roles, :join_table => 'spree_roles_users'
+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!
- end
+ def generate_api_key!
+ self.api_key = SecureRandom.hex(24)
+ save!
+ end
- def clear_api_key!
- self.api_key = nil
- save!
- end
+ 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 }
+ # 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,3 +1,5 @@
-Spree.user_class.class_eval do
- has_and_belongs_to_many :roles, :join_table => 'spree_roles_users'
+if Spree.user_class
+ Spree.user_class.class_eval do
+ has_and_belongs_to_many :roles, :join_table => 'spree_roles_users'
+ end
end
@@ -1,3 +1,5 @@
-Spree.user_class.class_eval do
- has_and_belongs_to_many :roles, :join_table => 'spree_roles_users'
+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 e15009e

Please sign in to comment.