Skip to content
This repository was archived by the owner on Jan 30, 2026. It is now read-only.
This repository was archived by the owner on Jan 30, 2026. It is now read-only.

Refactor: Katachi::KEY_PATTERN because :$key is too strange on first impressions #72

@jtannas

Description

@jtannas
# config
Katachi::KEY_PREFIX = :kt_

# adding a shape without the prefix prepends it
Katachi.add_shape(:foo, 'foo')
Katachi::Shapes[:kt_foo] # => 'foo'

# adding a shape with the prefix leaves it alone
Katachi.add_shape(:kt_bar, 'bar')
Katachi::Shapes[:kt_bar] # => 'bar'

# prefix can be either a string or a symbol; lookup responds accordingly
Katachi::KEY_PREFIX = 'ref:'
Katachi.add_shape(:baz, 'baz)
Katachi::Shapes['ref:baz'] = 'baz'

# Changing the prefix "alters" the keys of all existing shapes
Katachi::Shapes['ref:foo'] = 'foo'
Katachi::Shapes['ref:bar'] = 'bar'

# ^ Effectively this is placing a translation layer between the shape library and the user code

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions