Class: Macros::Ctx::Copy

Inherits:
Base
  • Object
show all
Defined in:
lib/macros/ctx/copy.rb

Instance Method Summary collapse

Methods inherited from Base

register

Constructor Details

#initialize(origin_key, destination_key) ⇒ Copy

Returns a new instance of Copy.



6
7
8
9
# File 'lib/macros/ctx/copy.rb', line 6

def initialize(origin_key, destination_key)
  @origin_key = origin_key
  @destination_key = destination_key
end

Instance Method Details

#call(ctx) ⇒ Object



11
12
13
14
15
# File 'lib/macros/ctx/copy.rb', line 11

def call(ctx, **)
  return false unless ctx[@origin_key]

  ctx[@destination_key] = ctx[@origin_key]
end