Class: Optics::HashLens

Inherits:
Lens
  • Object
show all
Defined in:
lib/optics.rb

Instance Method Summary collapse

Methods inherited from Lens

#combine, #get, #set

Constructor Details

#initialize(key) ⇒ HashLens

Returns a new instance of HashLens.



29
30
31
32
33
34
# File 'lib/optics.rb', line 29

def initialize(key)
  super(
    -> (subject) { subject[key] },
    -> (subject, value) { subject.merge(key => value) }
  )
end