Class: Spree::UserClassHandle Private

Inherits:
Object
  • Object
show all
Defined in:
app/models/spree/user_class_handle.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Note:

Placeholder for name of Spree.user_class to ensure later evaluation at runtime.

Unfortunately, it is possible for classes to get loaded before Spree.user_class has been set in the initializer. As a result, they end up with class_name: “” in their association definitions. For obvious reasons, that doesn't work.

For now, Rails does not call to_s on the instance passed in until runtime. So this little hack provides a wrapper around Spree.user_class so that we can basically lazy-evaluate it. Yay! Problem solved forever.

Configuration point for User model implementation.

`Spree::UserClassHandle` allows you to configure your own implementation of a User class or use an extnesion like `solidus_auth_devise`.

Instance Method Summary collapse

Instance Method Details

#to_sString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the name of the user class as a string.

Returns:

  • (String)

    the name of the user class as a string.

Raises:

  • (RuntimeError)

    if Spree.user_class is nil



21
22
23
24
# File 'app/models/spree/user_class_handle.rb', line 21

def to_s
  fail "'Spree.user_class' has not been set yet." unless Spree.user_class
  "::#{Spree.user_class}"
end