-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shared functionality: ApplicationForm? Mixin? Boilerplate? #1
Comments
If we're taking a cue from Pundit, they're using |
Hmm, yeah, an
Repeating this would be repetitive, but I'm wondering if it would be the most readable to people? Hmm. |
record record record Yeah, I like when variable names are specific, but willing to make concessions if we can hide some of the implementation details. It could also be "subject", which at least points back towards the name of the form class for context. Though I'm also aware of keeping consistency with previous artwork and the fact that pundit uses "record"… |
I was wondering if maybe this takes the form of some modules that import class methods: class ProjectForm
extend Microform::Delegator
attr_reader :project
delegates_to :project
# ...
end Then that |
Could open the door for other mixins as well… and make some functionality opt-in. |
I guess it does make me uncomfortable that it pushes functionality into the gem, instead of being "owned" by the project. In the case that there is a concrete |
I'm leaning towards an But I'm not sure what gets included there. A blank class? A class that somehow has the method_missing etc defined, or that defines a class method to do so in child forms. Would push for the simplest option, but I'm not sure yet what that is. |
class ApplicationForm < SimpleDelegator
end
class ProjectForm < ApplicationForm
def submit changeset
update changeset
end
end In effect that's the same that we're doing with |
Should microform also have an "install" generator that adds an ApplicationForm class to your project?
Or, taking a step back, how can some of the generic functionality like the
respond_to?
and other delegation method. This could either be a parent class, or a mix-in module, or simply repeated in each form class.The next question is, if functionality is shared in either of those way, does that mean that the instance variable needs to get more generic:
Or, is there some way that the instance variable is configured. This could be too clever:
Or, the instance variable could be inferred from the form name, e.g.
ProjectForm
assumes there will be a@project
instance variable assigned in the initializer.Do these "solutions" jump trough too many hoops to just avoid renaming the attribute to the more generic
record
?The text was updated successfully, but these errors were encountered: