Module: Shiftable::Single::ShiftSingleModulizer

Defined in:
lib/shiftable/single.rb

Overview

Creates anonymous Ruby Modules, containing dynamically built methods

Class Method Summary collapse

Class Method Details

.to_mod(signature) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
# File 'lib/shiftable/single.rb', line 70

def to_mod(signature)
  prefix = signature.method_prefix
  Module.new do
    define_method(:"#{prefix}shift_column") do
      signature.send("shift_#{signature.type}_column")
    end
    define_method(:"#{prefix}shift_single") do |shift_to:, shift_from:, bang: false|
      signature.shift_data!(shift_to: shift_to, shift_from: shift_from, bang: bang)
    end
  end
end