Exception: Spree::Publishable::MissingSerializerError

Inherits:
StandardError
  • Object
show all
Defined in:
app/models/concerns/spree/publishable.rb

Overview

Error raised when a model tries to publish an event but has no serializer defined

Instance Method Summary collapse

Constructor Details

#initialize(model_class) ⇒ MissingSerializerError

Returns a new instance of MissingSerializerError.



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'app/models/concerns/spree/publishable.rb', line 43

def initialize(model_class)
  serializer_name = "Spree::Events::#{model_class.name.demodulize}Serializer"
  super(
    "Missing event serializer for #{model_class.name}. " \
    "Please create #{serializer_name} that inherits from Spree::Events::BaseSerializer. " \
    "Example:\n\n" \
    "  class #{serializer_name} < Spree::Events::BaseSerializer\n" \
    "    protected\n\n" \
    "    def attributes\n" \
    "      {\n" \
    "        id: resource.id,\n" \
    "        # add other attributes here\n" \
    "        updated_at: timestamp(resource.updated_at)\n" \
    "      }\n" \
    "    end\n" \
    "  end"
  )
end