Class: Paquito::AllowNil

Inherits:
Object
  • Object
show all
Defined in:
lib/paquito/allow_nil.rb

Instance Method Summary collapse

Constructor Details

#initialize(coder) ⇒ AllowNil

Returns a new instance of AllowNil.



5
6
7
# File 'lib/paquito/allow_nil.rb', line 5

def initialize(coder)
  @coder = Paquito.cast(coder)
end

Instance Method Details

#dump(object) ⇒ Object



9
10
11
12
13
# File 'lib/paquito/allow_nil.rb', line 9

def dump(object)
  return nil if object.nil?

  @coder.dump(object)
end

#load(payload) ⇒ Object



15
16
17
18
19
# File 'lib/paquito/allow_nil.rb', line 15

def load(payload)
  return nil if payload.nil?

  @coder.load(payload)
end