Class: Loaf::Configuration
- Inherits:
-
Object
- Object
- Loaf::Configuration
- Defined in:
- lib/loaf/configuration.rb
Constant Summary collapse
- VALID_ATTRIBUTES =
[ :locales_path, :match ].freeze
- DEFAULT_LOCALES_PATH =
'/'
- DEFAULT_MATCH =
:inclusive
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Configuration
constructor
Setup this configuration.
-
#to_hash ⇒ Hash
Convert all properties into hash.
Constructor Details
#initialize(attributes = {}) ⇒ Configuration
Setup this configuration
19 20 21 22 23 24 25 |
# File 'lib/loaf/configuration.rb', line 19 def initialize(attributes = {}) VALID_ATTRIBUTES.each do |attr| default = self.class.const_get("DEFAULT_#{attr.to_s.upcase}") attr_value = attributes.fetch(attr) { default } send("#{attr}=", attr_value) end end |
Instance Method Details
#to_hash ⇒ Hash
Convert all properties into hash
32 33 34 |
# File 'lib/loaf/configuration.rb', line 32 def to_hash VALID_ATTRIBUTES.reduce({}) { |acc, k| acc[k] = send(k); acc } end |