Skip to content

Shared functionality: ApplicationForm? Mixin? Boilerplate? #1

@jackjennings

Description

@jackjennings

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:

def initialize project
  @project = project
end
# vs
def initialize record
  @record = record
end

Or, is there some way that the instance variable is configured. This could be too clever:

class ProjectForm
  include Micrform::Form[:project]
end

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions