mosquito-cr / mosquito

A background task runner for crystal applications supporting periodic (CRON) and manually queued jobs
MIT License
227 stars 24 forks source link

Custom serializer docs update #28

Closed jwoertink closed 5 years ago

jwoertink commented 5 years ago

The docs on the Wiki for the custom serializer needs a little updating. The current example wouldn't be able to compile

  class SpecialtyObject
    property name : String
    property value : Int32
+  def initialize(@name, @value)
+  end
  end

  def deserialize_specialty_object(raw : String) : SpecialtyObject
-    specialty = SpecialtyObject.new
    parts = raw.split "="
-    specialty.name = parts.first
-    specialty.value = parts.last
+   SpecialtyObject.new(name: parts.first, value: parts.last)
  end

In this case, the method has to return the instance of SpecialtyObject, plus crystal requires the instance variables to be initialized in some initialize method.

robacarp commented 5 years ago

Awesome, thank you for checking and editing!