class Polites::Settings

Settings is a wrapped around the combined configurations Polites writes to various Plist files in external directory.

Public Class Methods

from_directory(path) click to toggle source

Read all combined .plist files in a directory into a single data structure.

@param [#to_s, to_path] path root directory to look up .plist files in. @return [Polites::Settings]

# 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
new(settings = {}) click to toggle source

@param [Hash] settings

# File lib/polites/settings.rb, line 22
def initialize(settings = {})
  @settings = settings.to_h
  freeze
end

Public Instance Methods

[](key) click to toggle source

Look up a setting by key.

@param [String] key @return [Object]

# File lib/polites/settings.rb, line 31
def [](key)
  @settings[key]
end