Class: Curio

Inherits:
Module
  • Object
show all
Defined in:
lib/curio.rb,
lib/curio/version.rb

Overview

A mixin to define enumerable maps

Defined Under Namespace

Modules: Methods Classes: NotFoundError

Constant Summary collapse

VERSION =
'0.1.0'

Instance Method Summary collapse

Constructor Details

#initialize(key, type = String) ⇒ undefined

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize a collection object with given key and type

:key will be used to determine which method to call on items to get their unique identifier when adding them to the collection.

:type will be used to determine how to coerce the input when calling methods on the collection.

Parameters:

  • key (Symbol)
  • type (Class) (defaults to: String)


29
30
31
32
33
34
35
36
# File 'lib/curio.rb', line 29

def initialize(key, type = String)
  @key, @type = key, type

  define_key_method
  define_coerce_key_method

  freeze
end