Module: Tins::FromModule

Includes:
ParameterizedModule
Included in:
Module
Defined in:
lib/tins/dslkit.rb

Instance Method Summary collapse

Methods included from ParameterizedModule

#parameterize_for

Instance Method Details

#parameterize(opts = {}) ⇒ Object



546
547
548
549
550
551
552
553
554
555
556
557
558
# File 'lib/tins/dslkit.rb', line 546

def parameterize(opts = {})
  modul = opts[:module] or raise ArgumentError, 'option :module is required'
  import_methods = Array(opts[:methods])
  result = modul.dup
  remove_methods = modul.instance_methods.map(&:to_sym) - import_methods.map(&:to_sym)
  remove_methods.each do |m|
    begin
      result.__send__ :remove_method, m
    rescue NameError
    end
  end
  result
end