class Scorched::Options

Public Instance Methods

inspect() click to toggle source
# File lib/scorched/options.rb, line 36
def inspect
  "#<#{self.class}: local#{_inspect}, merged#{to_hash.inspect}>"
end
parent!(parent) click to toggle source

sets parent Options object and returns self

# File lib/scorched/options.rb, line 13
def parent!(parent)
  @parent = parent
  @cache = {}
  self
end
to_hash(inherit = true) click to toggle source
# 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