Procházet zdrojové kódy

use define_singleton_method to dynamically create methods for config options

Chris Mague před 7 roky
rodič
revize
4d01ea809f
1 změnil soubory, kde provedl 5 přidání a 7 odebrání
  1. 5 7
      lib/neoinfra/config.rb

+ 5 - 7
lib/neoinfra/config.rb

@@ -13,14 +13,12 @@ module NeoInfra
         File.join(File.dirname(File.expand_path(__FILE__)),
                   '..', '..', cfg)
       )
-    end
-
-    def neo4j
-      @config['neo4j']
-    end
 
-    def accounts
-      @config['accounts']
+      @config.keys.each do |c|
+        define_singleton_method(:"#{c}") do
+          @config[c]
+        end
+      end
     end
   end
 end