Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add checks for Spree.user_class to api, dash and promo user decorators
- Loading branch information
Showing
3 changed files
with
23 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |