Class: Moon::Application::Configuration
- Inherits:
-
Object
- Object
- Moon::Application::Configuration
- Defined in:
- lib/moon/application/configuration.rb
Overview
Application configuration.
Constant Summary collapse
- SCHEMA =
Configure::Schema.build { only :session, :route, :validator, :formatter nested { session { only :secret } route { only :http_method, :path, :actions argument_keys :http_method, :path } validator { only :model_class, :attributes } formatter { only :model_class, :object } } }.freeze
Instance Method Summary collapse
- #formatters ⇒ Object
-
#initialize(&block) ⇒ Configuration
constructor
A new instance of Configuration.
- #routes ⇒ Object
- #session ⇒ Object
- #validators ⇒ Object
Constructor Details
#initialize(&block) ⇒ Configuration
Returns a new instance of Configuration.
25 26 27 |
# File 'lib/moon/application/configuration.rb', line 25 def initialize(&block) @hash = Configure.process SCHEMA, &block end |
Instance Method Details
#formatters ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/moon/application/configuration.rb', line 46 def formatters formatters = { } [ @hash[:formatter] ].compact.flatten.each do |formatter_hash| model_class, object = formatter_hash.values_at :model_class, :object formatters[model_class] = object end formatters end |
#routes ⇒ Object
33 34 35 |
# File 'lib/moon/application/configuration.rb', line 33 def routes [ @hash[:route] ].compact.flatten end |
#session ⇒ Object
29 30 31 |
# File 'lib/moon/application/configuration.rb', line 29 def session @hash[:session] end |
#validators ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/moon/application/configuration.rb', line 37 def validators validators = { } [ @hash[:validator] ].compact.flatten.each do |validator_hash| model_class, attributes = validator_hash.values_at :model_class, :attributes validators[model_class] = attributes end validators end |