module Shiftable::Single::ShiftSingleModulizer

Creates anonymous Ruby Modules, containing dynamically built methods

Public Class Methods

to_mod(signature) click to toggle source
# 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

Private Instance Methods

to_mod(signature) click to toggle source
# 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