class MapDemTings::InputMapper

Public Class Methods

new(&block) click to toggle source

Simple mapper, can be used like a proc or lambda.

Example

def mapper

@mapper ||= MapDemTings::InputMapper.new do |input|
  Array.wrap( wrap_params[input.to_s] )
end

end

def author

mapper.map(:author)

end

This simplifies methods below, but does not cut down on the number of repeats.

def author

Array.wrap( wrap_params["author"] )

end

# File lib/map-dem-tings/input_mapper.rb, line 25
def initialize(&block)
  @block = block
end

Public Instance Methods

map(name) click to toggle source
# File lib/map-dem-tings/input_mapper.rb, line 29
def map(name)
  @block.call(name)
end