Sha256: ea75d96b3da3093cd161c52b98a2c580df47aa743579efbd74274388ff9ad132

Contents?: true

Size: 341 Bytes

Versions: 3

Compression:

Stored size: 341 Bytes

Contents

# like Enumerable#map, except if the receiver is not enumerable,
# i.e., a single value, then it transforms the single value.

module Enumerable
  alias_method :value_map, :map
end

class NilClass
  def value_map
    nil
  end
end

class Object
  def value_map
    yield self
  end
end

class Struct
  def value_map
    yield self
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
abstractivator-0.12.0 lib/abstractivator/value_map.rb
abstractivator-0.11.0 lib/abstractivator/value_map.rb
abstractivator-0.10.0 lib/abstractivator/value_map.rb