Repository navigation
Split flipside_entity options into their own macros - #4
Merged
Merged
Conversation
Each takes over one option of flipside_entity and registers the class as an entity on its own, so flipside_entity is only needed to register with the defaults. flipside_search_by and flipside_display_as take a block or a method name; for search that is a class method such as a scope. The options of flipside_entity are deprecated. Also clear the connection's statement cache when the RegisteredEntity spec recreates the users table, which made it fail in some orders. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The Flippable macros now set these on the class's registration instead of keeping their own copies, so the Symbol or Proc handling lives in one place. A Symbol given as search_by now names a class method; the deprecated options turn a column name into a search block. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The public documentation omits a registration macro and inaccurately describes identifier configuration as setting a table primary key.
2 open findings
What changed in this PR
Splits entity configuration into dedicated model macros while preserving deprecated options.
Changes:
- Adds search, display, and identifier macros with STI support.
- Centralizes entity setting interpretation.
- Updates tests, documentation, and changelog.
| File | Description |
|---|---|
app/models/flipside/flippable.rb |
Implements the new macros and inherited registration. |
lib/flipside/config/registered_entity.rb |
Centralizes search and display behavior. |
lib/flipside/config/entities.rb |
Preserves deprecated symbol-search semantics. |
spec/flipside/flippable_spec.rb |
Tests macros, STI, reloads, and deprecations. |
spec/flipside/registered_entity_spec.rb |
Tests revised entity configuration behavior. |
README.md |
Documents the new API and migration path. |
CHANGELOG.md |
Records additions and deprecations. |
🧠 Review effort: Balanced
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
flipside_search_by :name now matches the name column exactly, as search_by: :name always has, so moving to the new macro changes nothing. This drops the helper that translated the old meaning. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Clarify the purpose of flipside_identified_by. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Replaces the options of
flipside_entitywith one macro each:flipside_search_bytakes a block, run in the context of the class, or a column name to match exactly (flipside_search_by :name), assearch_by: :namedoes.flipside_display_astakes a block or the name of an instance method.flipside_entityis only needed to register with the defaults. They can be called in any order.Flipside.flippables. One that calls none is still displayed through its parent.search_by:,display_as:andidentified_by:options offlipside_entitystill work but are deprecated, to be removed in 1.0. Each maps directly onto its macro with the same meaning, so there are no breaking changes.Internals
RegisteredEntityis now the only place that interprets the Symbol or Proc settings. The macros set them on the class's registration, which is kept in an inherited class attribute, so a reloaded class starts over instead of keeping settings removed from its code.Also fixes an order-dependent spec failure: SQLite's statement cache kept the old
userscolumns whenregistered_entity_specrecreated the table.Testing
bundle exec rspec: 87 examples, 0 failures, checked across several random seeds.🤖 Generated with Claude Code