Class: Ki::KiConfig
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
Instance Method Summary collapse
- #config_file_path ⇒ Object
- #cors? ⇒ Boolean
- #database ⇒ Object
- #middleware ⇒ Object
- #read(environment) ⇒ Object
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
7 8 9 |
# File 'lib/ki/ki_config.rb', line 7 def config @config end |
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
7 8 9 |
# File 'lib/ki/ki_config.rb', line 7 def environment @environment end |
Instance Method Details
#config_file_path ⇒ Object
15 16 17 |
# File 'lib/ki/ki_config.rb', line 15 def config_file_path 'config.yml' end |
#cors? ⇒ Boolean
19 20 21 |
# File 'lib/ki/ki_config.rb', line 19 def cors? @config['cors'] end |
#database ⇒ Object
37 38 39 |
# File 'lib/ki/ki_config.rb', line 37 def database @config['database'] end |
#middleware ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ki/ki_config.rb', line 23 def middleware used_middleware = %w(ApiHandler CoffeeCompiler SassCompiler HamlCompiler PublicFileServer) used_middleware = @config['middleware'] if @config['middleware'] used_middleware = add_rm_middleware used_middleware, 'add_middleware', 'push' used_middleware = add_rm_middleware used_middleware, 'rm_middleware', 'delete' # convert middleware to ruby object used_middleware.uniq.map do |middleware| Object.const_get('Ki').const_get('Middleware').const_get(middleware) end end |
#read(environment) ⇒ Object
9 10 11 12 13 |
# File 'lib/ki/ki_config.rb', line 9 def read(environment) @environment = environment @config = YAML.load_file(config_file_path)[environment] @config['cors'] ||= true end |