Module: Shiftable::Collection::ShiftCollectionModulizer

Defined in:
lib/shiftable/collection.rb

Overview

Creates anonymous Ruby Modules, containing dynamically built methods

Class Method Summary collapse

Class Method Details

.to_mod(signature) ⇒ Object



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

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