Skip to content

STI subclasses with lifecycle creators do not work #189

@stevemadere

Description

@stevemadere

If ParentClass in a STI scheme has a lifecycle,
ChildClass cannot define functional lifecycle
creators.

If ChildClass attempts to define a lifecycle, it simply
end up extending the lifecycle of ParentClass.

This is mostly a problem if the ChildClass tries to define
any lifecycle create actions. If ChildClass contains code like
this:

lifecycle do
   state :child_specific_state
   create :child_specific_creator, become: child_specific_state
end

Then ParentClass gets a new creator called child_specific_creator.

When the lifecycle create action is executed, on ChildClass the
ChildClass::Lifecycle method returns the same value as ParentClass::Lifecycle.

Unfortunately, the lifecycle object itself contains a pointer to the
model.

If you have a look at the source code for the Hobo::Models::Lifecycle::Creator#run!
method, you will see it call lifecycle.model.new for any creator action and thus
only creates instances of ParentClass even if the creator called was child_specific_creator.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions