Module: Interchangeable

Defined in:
lib/interchangeable.rb,
lib/interchangeable/tables.rb,
lib/interchangeable/version.rb

Defined Under Namespace

Modules: Tables

Constant Summary collapse

VERSION =
"0.0.6"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.methodsObject

Returns the value of attribute methods.



28
29
30
# File 'lib/interchangeable.rb', line 28

def methods
  @methods
end

Class Method Details

.define(the_class, method_name, &block) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/interchangeable.rb', line 37

def define the_class, method_name, &block
  entry = Interchangeable.methods.select { |x| x.target == the_class && x.method_name && method_name == x.method_name }.first
  unless entry
    entry = Interchangeable.methods.select { |x| x.target == the_class.singleton_class && x.method_name && method_name == x.method_name }.first
  end
  entry.target.instance_eval do
    define_method method_name, &block
  end
  entry.implemented = true
  entry.default     = false
end

.missing_methodsObject



33
34
35
# File 'lib/interchangeable.rb', line 33

def missing_methods
  methods.reject { |m| m.implemented }
end