class Plumb::Key
def self.wrap(key)
def self.wrap(key) key.is_a?(Key) ? key : new(key) end
def eql?(other)
def eql?(other) other.hash == hash end
def hash
def hash @key.hash end
def initialize(key, optional: false)
def initialize(key, optional: false) key_s = key.to_s match = OPTIONAL_EXP.match(key_s) @node_name = :key @key = match[1] @to_sym = @key.to_sym @optional = !match[2].nil? ? true : optional freeze end
def inspect
def inspect "#{@key}#{'?' if @optional}" end
def optional?
def optional? @optional end
def to_s = @key
def to_s = @key