Skip to content

Inherit views (V2) #511

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

Open
wants to merge 6 commits into
base: release-2.0
Choose a base branch
from
Open

Inherit views (V2) #511

wants to merge 6 commits into from

Conversation

jhollinger
Copy link
Contributor

@jhollinger jhollinger commented Mar 13, 2025

Changes:

  • V2 blueprints inherit views from parents (like Legacy/V1)
  • view options to skip inheriting certain attributes from the parent (i.e. fields, options, extensions)
  • Freeze a blueprint/view's extensions, options and fields after it's first eval'd
  • Disallow defining a :default view
  • If a view is redefined, append to the existing definition instead of replacing it (like Legacy/V1)
    • If they want to replace it, they can do so using view's new field/options/extension options

Legacy/V1's "identifier" view can be emulated like this:

class ApplicationBlueprint < Blueprinter::V2::Base
  field :id

  # without `fields: false`, this view would inherit fields from the top-level of child Blueprints
  view :identifier, fields: false do
    field :id
  end
end

@jhollinger jhollinger added the enhancement New feature or request label Mar 13, 2025
@jhollinger jhollinger requested review from ritikesh and a team as code owners March 13, 2025 17:58
@jhollinger jhollinger force-pushed the jh/2.0-inherit-views branch from 9dbfa69 to f01f713 Compare March 14, 2025 18:52
@jhollinger jhollinger force-pushed the jh/2.0-inherit-views branch from dd86213 to fb230a0 Compare April 1, 2025 15:31
@jhollinger jhollinger requested a review from lessthanjacob April 1, 2025 16:53
@jhollinger jhollinger force-pushed the jh/2.0-inherit-views branch 6 times, most recently from 080e83d to 02009df Compare April 5, 2025 15:46
@siba2893
Copy link

siba2893 commented Apr 9, 2025

This looks amazing! Waiting for this to get merged

@jhollinger jhollinger force-pushed the jh/2.0-inherit-views branch from 02009df to a16d278 Compare April 29, 2025 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants