Class: Ve::Manager
- Inherits:
-
Object
- Object
- Ve::Manager
- Defined in:
- lib/ve.rb
Constant Summary collapse
- @@config_for =
{}
Class Method Summary collapse
- .provider_for(language, function) ⇒ Object
-
.register(klass, language) ⇒ Object
TODO: Make a difference between what features are available locally and what requires contacting external Ves.
- .set_default_config_for(klass, config = {}) ⇒ Object
Class Method Details
.provider_for(language, function) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/ve.rb', line 19 def self.provider_for(language, function) provider = @@provider_for[language.to_sym][function.to_sym] if provider.is_a?(Class) config = @@config_for[provider] || {} provider = @@provider_for[language.to_sym][function.to_sym].new(config) @@provider_for[language.to_sym][function.to_sym] = provider end provider end |
.register(klass, language) ⇒ Object
TODO: Make a difference between what features are available locally and what requires contacting external Ves
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ve.rb', line 31 def self.register(klass, language) @@provider_for ||= {} # 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 = klass.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] = klass end end |
.set_default_config_for(klass, config = {}) ⇒ Object
15 16 17 |
# File 'lib/ve.rb', line 15 def self.set_default_config_for(klass, config = {}) @@config_for[klass] = config end |