Module: Readthis::Passthrough

Defined in:
lib/readthis/passthrough.rb

Overview

The `Passthrough` serializer performs no encoding on objects. It should be used when caching simple string objects when the overhead of marshalling or other serialization isn't desired.

Class Method Summary collapse

Class Method Details

.dump(value) ⇒ String

Dump an object to string, without performing any encoding on it.

Parameters:

  • value (Object)

    Any object to be dumped as a string. Frozen strings will be duplicated.

Returns:

  • (String)

    The converted object.


15
16
17
18
19
20
# File 'lib/readthis/passthrough.rb', line 15

def self.dump(value)
  case value
  when String then value.dup
  else value.to_s
  end
end

.load(value) ⇒ String

Load an object without modifying it at all.

Parameters:

  • value (String)

    The object to return, expected to be a string.

Returns:

  • (String)

    The original value.


27
28
29
# File 'lib/readthis/passthrough.rb', line 27

def self.load(value)
  value
end