Module: KeyDial

Included in:
Array, Hash, Struct
Defined in:
lib/key_dial.rb,
lib/key_dial/version.rb,
lib/key_dial/coercion.rb,
lib/key_dial/key_dialler.rb

Defined Under Namespace

Modules: Coercion Classes: KeyDialler

Constant Summary collapse

VERSION =
"1.2.0"

Instance Method Summary collapse

Instance Method Details

#call(*lookup) ⇒ Object

Called directly on a keyed object, immediately dials and calls the keys specified as arguments. Returns the value found, or nil. A default cannot be specified.

Parameters:

  • lookup

    The keys to attempt to retrieve.



21
22
23
# File 'lib/key_dial.rb', line 21

def call(*lookup)
	return KeyDialler.new(self, *lookup).call
end

#to_dial(*lookup) ⇒ Object Also known as: dial

Called on a Hash, Array or Struct, returns a KeyDialler object, ready to dial keys against that Hash, Array or Struct.

Parameters:

  • lookup

    Parameters to this method form initial keys to dial. This is unnecessary but works anyway. For simplicity, dial keys by accessing them as if KeyDialler were a keyed object itself.



11
12
13
# File 'lib/key_dial.rb', line 11

def to_dial(*lookup)
	return KeyDialler.new(self, *lookup)
end