Class: Object

Inherits:
BasicObject
Defined in:
lib/coo-coo/core_ext.rb

Class Method Summary collapse

Class Method Details

.define_once(method, &definition) ⇒ Object



26
27
28
29
30
# File 'lib/coo-coo/core_ext.rb', line 26

def self.define_once(method, &definition)
  unless instance_defines?(method)
    define_method(method, &definition)
  end
end

.delegate(*args) ⇒ Object



32
33
34
35
36
37
38
39
40
# File 'lib/coo-coo/core_ext.rb', line 32

def self.delegate(*args)
  opts = args.pop
  
  args.each do |meth|
    define_method(meth) do |*a|
      send(opts[:to]).send(meth, *a)
    end
  end
end

.instance_defines?(method) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/coo-coo/core_ext.rb', line 22

def self.instance_defines?(method)
  instance_methods.include?(method)
end