Open oneiros opened 2 months ago
Hey @oneiros sorry I've been afk for the past couple weeks but great write up and love the direction you are taking this.
Rails does account for a good amount of ruby apps and keeping rails support is very important. That being said I still agree it would be nice to have the AS functionality extracted out into another gem like phlex does to allow phlex_ui to be used anywhere even without rails.
So I fully embrace going with option 5.
I can start a new project and we can test abstracting out the builder functions into that gem and also update the documentation site to reflect that.
I updated my PR (#43) and removed Select::Builder
. Feel free to reintroduce it in a seperate gem at a later point.
(FWIW, I would have loved to have helped with that, but I am starting a new job next monday and will probably not have time for that in the foreseeable future :frowning_face:).
@oneiros Thanks for the suggestions and for the help.
As described in #43 I tried to get rid of ActiveSupport. As it turns out, this is not so simple.
PhlexUI::Select::Builder
makes use of theString
extensionsclassify
,contantize
andunderscore
. These methods are not trivial to reimplement. The AS versions have been refined over a long time and cover many edge cases.If we want to keep
PhlexUI::Select::Builder
s functionality mostly as-is, that would leave us with the following options imo:But I think there are other, better ways, if we consider what
PhlexUI::Select::Builder
actually does. I think it is a kind of outlier because I am pretty sure it is the only component / builder that is built with usage in rails apps explicitly in mind. The API and the fact that it constructs form inputname
attributes that follow rails conventions makes me think it was created for usage in rails forms first and foremost. But not evenPhlexUI::Form::Builder
is tailored that way (instead making thename
attribute of inputs a mandatory parameter).So I believe another, possibly better set of options would be to either:
PhlexUI::Select::Builder
altogether. I believe it is only useful for a narrow use case anyway and using the "deconstructed" version is not that hard.phlex_ui_rails
and movePhlexUI::Select::Builder
there. This might be a good first step for providing rails specific functionality. In the long run, at least a form builder for rails apps would be brilliant I think, so this might make sense.PhlexUI::Select::Builder
to work without magic string transformations. I do not think it would have to change much, but there are different approaches to this.(Personally, I tend towards 4, because something about the API of
PhlexUI::Select::Builder
feels off to me, but I cannot point my finger at what exactly it is. Thus I am not sure I could produce a better one.)What do you think?