Class: Houston::ParamsSerializer

Inherits:
Serializer show all
Defined in:
lib/houston/params_serializer.rb

Instance Method Summary collapse

Methods inherited from Serializer

#assert_serializable!, #initialize

Constructor Details

This class inherits a constructor from Houston::Serializer

Instance Method Details

#dump(object) ⇒ Object

Raises:

  • (ArgumentError)


10
11
12
13
14
15
# File 'lib/houston/params_serializer.rb', line 10

def dump(object)
  object = {} if object.nil?
  object = object.to_h if !object.is_a?(Hash) && object.respond_to?(:to_h)
  raise ArgumentError, "params must be a Hash, but it is a #{object.class}" unless object.is_a?(Hash)
  super object
end

#load(string) ⇒ Object



6
7
8
# File 'lib/houston/params_serializer.rb', line 6

def load(string)
  super(string || "{}")
end