Skip to content

Conversation

@Dahie
Copy link

@Dahie Dahie commented Jan 5, 2026

This is still work in progress and will get cleanup later. I may also take out the delegation into a plugin

Dahie added 5 commits January 4, 2026 07:50
The results are analogue to Ruby-on-Rails to support namespaced classes.
It's also more predictable - the original implementation would change encoding and drop characters.
This change was motivated by two things:
- Components needed to be declared using the class name, which made it necessary to manually reorder required imports.
- Reusing Components was hard and I often ended with many classes doing the same things

So what this does is to give the option to declare Components as underscored symbol names.
Declaration with class names as before is still supported.
When a component is declared, the name can be given as Class name, underscored symbol or with an own title - if a class_name is given in the options string.

Internally in EntityStore and ComponentStore all index to the name symbol now.
This is a convencience thing for simple Components.
If you only have one value in the component, like a list, it makes the calling methods of the list nicer.

```
class A < Draco::Component
    attribute :list, default: []
    delegate :each, :count, :<<, :[], to: :list
end

a = A.new
a << "add me to the list"
a.count = 1
@Dahie Dahie force-pushed the extend-component-definition-api branch from 432b2c6 to b4b9d9b Compare January 6, 2026 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant