Sha256: c59f060fb47706e53e9f2d0c2d87073f16c51f341c2cedadf63ee80a30186e65
Contents?: true
Size: 860 Bytes
Versions: 44
Compression:
Stored size: 860 Bytes
Contents
module Spree # 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. class UserClassHandle # @return [String] the name of the user class as a string. # @raise [RuntimeError] if Spree.user_class is nil def to_s fail "'Spree.user_class' has not been set yet." unless Spree.user_class "::#{Spree.user_class}" end end end
Version data entries
44 entries across 44 versions & 1 rubygems