Browse Source

use define_singleton_method to dynamically create methods for config options

Chris Mague 7 years ago
parent
commit
4d01ea809f
1 changed files with 5 additions and 7 deletions
  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