class Liquid::StaticRegisters
Constants
- UNDEFINED
Attributes
static[R]
Public Class Methods
new(registers = {})
click to toggle source
# File lib/liquid/static_registers.rb, line 7 def initialize(registers = {}) @static = registers.is_a?(StaticRegisters) ? registers.static : registers @registers = {} end
Public Instance Methods
[](key)
click to toggle source
# File lib/liquid/static_registers.rb, line 16 def [](key) if @registers.key?(key) @registers[key] else @static[key] end end
[]=(key, value)
click to toggle source
# File lib/liquid/static_registers.rb, line 12 def []=(key, value) @registers[key] = value end
delete(key)
click to toggle source
# File lib/liquid/static_registers.rb, line 24 def delete(key) @registers.delete(key) end
fetch(key, default = UNDEFINED, &block)
click to toggle source
# File lib/liquid/static_registers.rb, line 30 def fetch(key, default = UNDEFINED, &block) if @registers.key?(key) @registers.fetch(key) elsif default != UNDEFINED @static.fetch(key, default, &block) else @static.fetch(key, &block) end end
key?(key)
click to toggle source
# File lib/liquid/static_registers.rb, line 40 def key?(key) @registers.key?(key) || @static.key?(key) end