Class: Scorched::Options
- Inherits:
-
Hash
- Object
- Hash
- Scorched::Options
- Extended by:
- DynamicDelegate
- Defined in:
- lib/scorched/options.rb
Instance Method Summary collapse
- #inspect ⇒ Object
-
#parent!(parent) ⇒ Object
sets parent Options object and returns self.
- #to_hash(inherit = true) ⇒ Object
Methods included from DynamicDelegate
Instance Method Details
#inspect ⇒ Object
36 37 38 |
# File 'lib/scorched/options.rb', line 36 def inspect "#<#{self.class}: local#{_inspect}, merged#{to_hash.inspect}>" end |
#parent!(parent) ⇒ Object
sets parent Options object and returns self
13 14 15 16 17 |
# File 'lib/scorched/options.rb', line 13 def parent!(parent) @parent = parent @cache = {} self end |
#to_hash(inherit = true) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/scorched/options.rb', line 19 def to_hash(inherit = true) @cache ||= {} unless @cache[:self] == self @cache[:self] = self._to_h @cache[:merged] = nil end if inherit && Hash === @parent unless @cache[:parent] == @parent.to_hash @cache[:parent] = @parent.to_hash @cache[:merged] = nil end @cache[:merged] ||= @cache[:parent].merge(@cache[:self]) else @cache[:self] end end |