Class: Polites::Settings
- Inherits:
-
Object
- Object
- Polites::Settings
- Defined in:
- lib/polites/settings.rb
Overview
Settings is a wrapped around the combined configurations Polites writes to various Plist files in external directory.
Class Method Summary collapse
-
.from_directory(path) ⇒ Polites::Settings
Read all combined .plist files in a directory into a single data structure.
Instance Method Summary collapse
-
#[](key) ⇒ Object
Look up a setting by key.
-
#initialize(settings = {}) ⇒ Settings
constructor
A new instance of Settings.
Constructor Details
#initialize(settings = {}) ⇒ Settings
Returns a new instance of Settings.
22 23 24 25 |
# File 'lib/polites/settings.rb', line 22 def initialize(settings = {}) @settings = settings.to_h freeze end |
Class Method Details
.from_directory(path) ⇒ Polites::Settings
Read all combined .plist files in a directory into a single data structure.
14 15 16 17 18 19 |
# File 'lib/polites/settings.rb', line 14 def self.from_directory(path) Pathname(path) .glob('.*.plist') .inject({}) { |s, f| s.merge Plist.new(f).to_h } .then { |s| new(s) } end |
Instance Method Details
#[](key) ⇒ Object
Look up a setting by key.
31 32 33 |
# File 'lib/polites/settings.rb', line 31 def [](key) @settings[key] end |