Skip to content

Commit

Permalink
Merge pull request rails#32001 from ydakuka/patch-2
Browse files Browse the repository at this point in the history
Missing backquote, extra end keyword [ci skip]
  • Loading branch information
arunagw authored Feb 15, 2018
2 parents fe6adf4 + 007c791 commit 4865f6b
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions guides/source/active_job_basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ Supported types for arguments
ActiveJob supports the following types of arguments by default:

- Basic types (`NilClass`, `String`, `Integer`, `Fixnum`, `Bignum`, `Float`, `BigDecimal`, `TrueClass`, `FalseClass`)
- `Symbol
- `Symbol`
- `ActiveSupport::Duration`
- `Date`
- `Time`
Expand Down Expand Up @@ -389,25 +389,24 @@ You can extend list of supported types for arguments. You just need to define yo

```ruby
class MoneySerializer < ActiveJob::Serializers::ObjectSerializer
# Check if this object should be serialized using this serializer.
def serialize?(argument)
argument.is_a? Money
end
# Check if this object should be serialized using this serializer.
def serialize?(argument)
argument.is_a? Money
end

# Convert an object to a simpler representative using supported object types.
# The recommended representative is a Hash with a specific key. Keys can be of basic types only.
# You should call `super` to add the custom serializer type to the hash
def serialize(object)
super(
"cents" => object.cents,
"currency" => object.currency
)
end
# Convert an object to a simpler representative using supported object types.
# The recommended representative is a Hash with a specific key. Keys can be of basic types only.
# You should call `super` to add the custom serializer type to the hash
def serialize(object)
super(
"cents" => object.cents,
"currency" => object.currency
)
end

# Convert serialized value into a proper object
def deserialize(hash)
Money.new hash["cents"], hash["currency"]
end
# Convert serialized value into a proper object
def deserialize(hash)
Money.new hash["cents"], hash["currency"]
end
end
```
Expand Down

0 comments on commit 4865f6b

Please sign in to comment.