Sha256: 478e6da81024e50fc6fb19c382d19ebf03139cb828c938ff26477f24bc23c6ce
Contents?: true
Size: 839 Bytes
Versions: 2
Compression:
Stored size: 839 Bytes
Contents
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 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 end private def layers @layers end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pears-0.0.2 | lib/pears/subject.rb |
pears-0.0.1 | lib/pears/subject.rb |