Module: Kernel

Defined in:
lib/cuts/cut.rb

Instance Method Summary collapse

Instance Method Details

#cut(klass, &block) ⇒ Object

Cut convienence method.



172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/cuts/cut.rb', line 172

def cut(klass, &block)
  case klass
  when Array
    name, klass = *klass
  else
    name = nil
  end

  cut = Cut.new(klass, &block)

  # How to handle main, but not other instance spaces?
  #klass.modspace::const_set(klass.basename, cut)
  mod = (Module === self ? self : Object)
  mod.const_set(cutname, cut)  # <<- this is what we don't have in Cut.new

  return cut
end