Class: Exports

Inherits:
Object
  • Object
show all
Defined in:
lib/exports.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, function) ⇒ Object



2
3
4
5
6
# File 'lib/exports.rb', line 2

def method_missing(name, function)
  return unless name.to_s.end_with?('=')
  name = name[0..-2].to_sym
  functions[name] = function
end

Instance Method Details

#functionsObject



12
13
14
# File 'lib/exports.rb', line 12

def functions
  @functions ||= {}
end

#import(*keys) ⇒ Object



8
9
10
# File 'lib/exports.rb', line 8

def import(*keys)
  keys.map { |k| functions[k] }
end