Class: Ve::Manager

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

Class Method Summary collapse

Class Method Details

.provider_for(language, function) ⇒ Object



13
14
15
# File 'lib/ve.rb', line 13

def self.provider_for(language, function)
  @@provider_for[language.to_sym][function.to_sym]
end

.register(klass, language) ⇒ Object

TODO: Make a difference between what features are available locally and what requires contacting external Ves



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ve.rb', line 19

def self.register(klass, language)
  @@provider_for ||= {}
  provider = klass.new
  # This won't work if people start monkey patching the providers with public methods that arent abilities
  # It's also not pretty, but kinda nifty
  provider_name = provider.class.to_s.split('::').last
  parse_class = Kernel.class_eval("Ve::Parse::#{provider_name}")
  abilities = parse_class.public_instance_methods - Object.public_instance_methods
  abilities.each do |a|
    @@provider_for[language.to_sym] ||= {}
    @@provider_for[language.to_sym][a] = provider
  end
end