thoughtbot / thoughtbot/factory_bot

Question: Possible to get reference to the build_class from initialize_with?

Open
#1,575 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
8.2k
Forks
2.6k
PR merge metrics
No merged PRs in 30d

Description

I'm working with STI and am customizing our initialize_with block. However, there are some conditions we'd like to put in place that require introspection on the class in question.

It seems there are a number of layers of indirection around the class (decorator, @component, @build_class, etc). Is there a way to get a reference to the factory's class (essentially new.class, but without invoking new) from within the initialize_with block?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the initialize_with entry point and trace the decorator, @component, and @build_class layers mentioned in the issue. Determine whether the factory's class can be referenced without invoking new, then document the supported behavior or clarify the API needed if it cannot.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.