Tools

A library of utility services and concerns.

Constant Maps

A ConstantMap provides an enumerable interface for defining a group of constants.

require 'sleeping_king_studios/tools/toolbox/constant_map'

UserRoles = SleepingKingStudios::Tools::Toolbox::ConstantMap.new(
  GUEST: 'guest',
  USER:  'user',
  ADMIN: 'admin'
).freeze

UserRoles::GUEST
#=> 'guest'

UserRoles.user
#=> 'user'

UserRoles.all
#=> { GUEST: 'guest', USER: 'user', ADMIN: 'admin' }

The class reference for SleepingKingStudios::Tools::Toolbox::ConstantMap can be found in Reference.

Contents

Accessing Values

The defined values can be accessed a few different ways:

Delegated Methods

Each ConstantMap defines the following Hash methods:

The data can also be accessed as a read-only Hash using #to_h.


Back to Documentation