Sha256: 07bfa98b8a70a7e29a8e4460bcf8fde36b9d67c6d8f61af05cd69e18e7bac8f7
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 KB
Contents
module SettingsJs module Backends # Public: SettingsLogic backend implementation to get values of Settings from string. # # klass - Class which is SettingsLogic in the application. # # Examples # # settingsjs_backend = Settings::Backends::SettingsLogic.new(MySettings) # class SettingsLogic attr_accessor :klass def initialize(klass) self.klass = klass end # Public: Use application Settingslogic class to get values of a key. # # base_key - String with path keys seperated by dots. # # Examples # # Settingsjs::Backends::SettingsLogic.new(MySettings).to_hash('key1.subkey1_1') # # => { subkey1_1: 'Awesome value!' } # # Returns the Hash value. def to_hash(base_key) keys = base_key.split(/\./) hash_key = keys.last base_hash = klass.send(keys.shift) keys.each { |key| base_hash = base_hash.send(key) } { hash_key => base_hash } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
settings_js-0.3.0 | lib/settings_js/backends/settings_logic.rb |