Class: Nodepile::KeyedArrayAccessor::PseudoROHashForDeconstruct

Inherits:
Object
  • Object
show all
Defined in:
lib/nodepile/keyed_array.rb

Overview

Internal implementation to optimize pattern matching Does two main things:

  1. Converts keys passed in to string type (allowing symbols to be used for pattern matching)
  2. Makes it looks like metadata and data occupy the same keyspace regardless of the setting of the @metadata_key_prefix

Instance Method Summary collapse

Constructor Details

#initialize(keyed_array) ⇒ PseudoROHashForDeconstruct



353
# File 'lib/nodepile/keyed_array.rb', line 353

def initialize(keyed_array) = @kaa = keyed_array

Instance Method Details

#[](k) ⇒ Object



355
# File 'lib/nodepile/keyed_array.rb', line 355

def [](k) = (@kaa..nil? ? (@kaa[k.to_s] || @kaa.(k.to_s)) : @kaa[k.to_s] )

#include?(k) ⇒ Boolean



354
# File 'lib/nodepile/keyed_array.rb', line 354

def include?(k) = @kaa.include?(k.to_s) || @kaa.(k.to_s)