Sha256: ab9b78c857eadcaa62197d6b5d39d9b9a10725e12477e7391e31bf117b77e3ba

Contents?: true

Size: 557 Bytes

Versions: 5

Compression:

Stored size: 557 Bytes

Contents

module Monolens
  module Object
    class Keys
      include Lens

      signature(Type::Object, Type::Object, {
        lenses: [Type::Lenses, false],
      })

      def call(arg, world = {})
        is_hash!(arg, world)

        lenses = option(:lenses)
        dup = {}
        arg.each_pair do |attr, value|
          deeper(world, attr) do |w|
            lensed = lenses.call(attr, w)
            lensed = lensed.to_sym if lensed && attr.is_a?(Symbol)
            dup[lensed] = value
          end
        end
        dup
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
monolens-0.6.4 lib/monolens/stdlib/object/keys.rb
monolens-0.6.3 lib/monolens/stdlib/object/keys.rb
monolens-0.6.2 lib/monolens/stdlib/object/keys.rb
monolens-0.6.1 lib/monolens/stdlib/object/keys.rb
monolens-0.6.0 lib/monolens/stdlib/object/keys.rb