Class: Recruit::Duck
- Inherits:
-
Object
- Object
- Recruit::Duck
- Defined in:
- lib/speq/recruit.rb
Overview
Mostly just quacks like one
Instance Method Summary collapse
-
#initialize(**mapping) ⇒ Duck
constructor
A new instance of Duck.
Constructor Details
#initialize(**mapping) ⇒ Duck
Returns a new instance of Duck.
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/speq/recruit.rb', line 17 def initialize(**mapping) mapping.each do |method_name, value| if mapping[method_name].respond_to?(:call) define_singleton_method(method_name, value) else define_singleton_method(method_name, &-> { mapping[method_name] }) define_singleton_method( "#{method_name}=".to_sym, &->(val) { mapping[method_name] = val } ) end end end |