class Rekey::From

Public Class Methods

new(key) click to toggle source
# File lib/rekey/from.rb, line 4
def initialize key
  @key = key
end

Public Instance Methods

rekey(obj) click to toggle source
# File lib/rekey/from.rb, line 8
def rekey obj
  obj[@key]
end
unkey(obj) click to toggle source
# File lib/rekey/from.rb, line 12
def unkey obj
  obj.map do |key, value|
    if key == @key
      {}
    else
      Hash[key, value]
    end
  end.reduce({}, &:merge)
end