Class: Embargoed::Configuration
- Inherits:
-
Object
- Object
- Embargoed::Configuration
- Defined in:
- lib/embargoed/configuration.rb
Constant Summary collapse
- SETTINGS =
[ :app_root, :named_maintenance_file_paths, :maintenance_pages_path, :default_maintenance_page, :default_reason, :default_allowed_ips, :skip_middleware, :default_allowed_paths, :default_response_code, :default_retry_after, :i18n ].freeze
Instance Method Summary collapse
- #app_root ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #named_maintenance_file_paths=(named_paths) ⇒ Object
- #update(settings_hash) ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/embargoed/configuration.rb', line 22 def initialize @skip_middleware = false @app_root = '.' @named_maintenance_file_paths = {default: app_root.join('tmp', 'maintenance.yml').to_s} @maintenance_pages_path = app_root.join('public').to_s @default_maintenance_page = ::MaintenancePage::HTML @default_reason = "The site is temporarily down for maintenance.\nPlease check back soon." @default_allowed_paths = [] @default_allowed_ips = [] @default_response_code = 503 @default_retry_after = 7200 # 2 hours by default @i18n = ::OrderedOptions.new @i18n.railties_load_path = [] @i18n.load_path = [] @i18n.fallbacks = ::OrderedOptions.new @i18n.enabled = false @i18n.use_language_header = false end |
Instance Method Details
#app_root ⇒ Object
41 42 43 |
# File 'lib/embargoed/configuration.rb', line 41 def app_root Pathname.new(@app_root.to_s) end |
#named_maintenance_file_paths=(named_paths) ⇒ Object
45 46 47 48 |
# File 'lib/embargoed/configuration.rb', line 45 def named_maintenance_file_paths=(named_paths) # Force keys to symbols @named_maintenance_file_paths = Hash[named_paths.map { |k, v| [k.to_sym, v] }] end |
#update(settings_hash) ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/embargoed/configuration.rb', line 50 def update(settings_hash) settings_hash.each do |setting, value| unless SETTINGS.include? setting.to_sym raise ArgumentError, "invalid setting: #{setting}" end self.public_send "#{setting}=", value end end |