Class: FlatMap::Mapping::Reader::Formatted

Inherits:
Basic
  • Object
show all
Extended by:
ActiveSupport::Autoload
Includes:
Formats
Defined in:
lib/flat_map/mapping/reader/formatted.rb

Overview

Formatted reader reads the value the same as Basic reader does, but additionally performs value postprocessing. All processing methods are defined within Formats module. The method is chosen based on the :format option when the mapping is defined.

Defined Under Namespace

Modules: Formats

Instance Attribute Summary

Attributes inherited from Basic

#mapping

Instance Method Summary collapse

Methods included from Formats

#enum, #i18n_l

Constructor Details

#initialize(mapping, format) ⇒ Formatted

Initialize the reader with a mapping and a format.

Parameters:



17
18
19
# File 'lib/flat_map/mapping/reader/formatted.rb', line 17

def initialize(mapping, format)
  @mapping, @format = mapping, format
end

Instance Method Details

#read(*args) ⇒ Object

Read the value just like the Basic reader does, but additionally send the returned value to its format method.

Additional arguments will be passed to formatting function of the mapping’s format.

Returns:

  • (Object)

    formatted value



28
29
30
# File 'lib/flat_map/mapping/reader/formatted.rb', line 28

def read(*args)
  format_value(super, *args)
end