Class: Monolens::Object::Values

Inherits:
Object
  • Object
show all
Includes:
Lens
Defined in:
lib/monolens/object/values.rb

Instance Attribute Summary

Attributes included from Lens

#options

Instance Method Summary collapse

Methods included from Lens

#fetch_on, #is_array!, #is_enumerable!, #is_hash!, #is_string!, #option

Constructor Details

#initialize(lens) ⇒ Values

Returns a new instance of Values.



6
7
8
9
# File 'lib/monolens/object/values.rb', line 6

def initialize(lens)
  super({})
  @lens = Monolens.lens(lens)
end

Instance Method Details

#call(arg, *rest) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/monolens/object/values.rb', line 11

def call(arg, *rest)
  is_hash!(arg)

  dup = arg.dup
  arg.each_pair do |attr, value|
    dup[attr] = @lens.call(value)
  end
  dup
end