Class: Tins::NamedSet

Inherits:
Set show all
Defined in:
lib/tins/named_set.rb

Overview

NamedSet extends Ruby’s Set class to include a descriptive name.

This class provides all the functionality of Ruby’s standard Set while adding a named identifier that can be useful for debugging, logging, and identification purposes. The name is stored as an instance variable and can be accessed or modified through the name accessor.

Examples:

Basic usage

set = Tins::NamedSet.new("user_roles")
set.add(:admin)
set.add(:user)
puts set.name  # => "user_roles"
puts set.to_a  # => [:admin, :user]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ NamedSet

Initializes a new NamedSet with the given name.

Parameters:

  • name (String)

    A descriptive name for this set



22
23
24
25
# File 'lib/tins/named_set.rb', line 22

def initialize(name)
  @name = name
  super()
end

Instance Attribute Details

#nameString

Gets or sets the name of this NamedSet.

Returns:

  • (String)

    The current name of the set



30
31
32
# File 'lib/tins/named_set.rb', line 30

def name
  @name
end