Sha256: fd31e0c33e4731ff59a4989aea08bbc3a3fbf2053588720b5c6c48641439685e
Contents?: true
Size: 927 Bytes
Versions: 1
Compression:
Stored size: 927 Bytes
Contents
# frozen_string_literal: true module Liquid class StaticRegisters attr_reader :static def initialize(registers = {}) @static = registers.is_a?(StaticRegisters) ? registers.static : registers @registers = {} end def []=(key, value) @registers[key] = value end def [](key) if @registers.key?(key) @registers[key] else @static[key] end end def delete(key) @registers.delete(key) end UNDEFINED = Object.new def fetch(key, default = UNDEFINED, &block) if @registers.key?(key) @registers.fetch(key) elsif default != UNDEFINED if block_given? @static.fetch(key, &block) else @static.fetch(key, default) end else @static.fetch(key, &block) end end def key?(key) @registers.key?(key) || @static.key?(key) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
liquid-5.3.0 | lib/liquid/static_registers.rb |