Sha256: 19d76b9ce34d7790dbcad8d21e68cf10a38416d68fb2873c06c4eed597dd0355
Contents?: true
Size: 975 Bytes
Versions: 10
Compression:
Stored size: 975 Bytes
Contents
require 'active_support/core_ext/hash/indifferent_access' module Pears # A subject is a collection of settings. # You could different Pears::Subjects in your application for different parts # of its domain. for instance: application_settings, theming or translations. class Subject attr_reader :name def initialize(name, *layers) @name = name @layers = layers Pears.subjects << self end def [](key) project[key] end def keys project.keys end def has_key?(key) project.has_key? key end def dig(*args) project.dig(*args) end def push_layer(layer) @layers << layer end # Projects the layers to a hash that van be used as a single source of truth. def project layers.reverse.reduce(Hash.new) do |hash, layer| hash.deep_merge(layer.data) end.with_indifferent_access end private def layers @layers end end end
Version data entries
10 entries across 10 versions & 1 rubygems