Closed kyori19 closed 2 months ago
association :parent, blueprint: ParentBlueprint, if: :include_parent? in ChildBlueprint calls ParentBlueprint.include_parent?
association :parent, blueprint: ParentBlueprint, if: :include_parent?
ChildBlueprint
ParentBlueprint.include_parent?
association :parent, blueprint: ParentBlueprint, if: :include_parent? in ChildBlueprint should call ChildBlueprint.include_parent?
ChildBlueprint.include_parent?
Use this script to reproduce the problem.
#!/usr/bin/env ruby # frozen_string_literal: true require 'bundler/inline' require 'json' gemfile do source 'https://rubygems.org' # uncomment this to check previous behavior # gem 'blueprinter', '= 1.0.2' gem 'blueprinter', '= 1.1.0' end Parent = Struct.new(:name, keyword_init: true) Child = Struct.new(:parent, :name, keyword_init: true) class ParentBlueprint < Blueprinter::Base field :name end class ChildBlueprint < Blueprinter::Base def self.include_parent?(_, _, _) true end field :name association :parent, blueprint: ParentBlueprint, if: :include_parent? end parent = Parent.new( name: 'Parent', ) child = Child.new( parent:, name: 'Child', ) pp ChildBlueprint.render_as_hash(child)
- OS: Ubuntu 22.04 - Browser Name and version: N/A - Ruby Version: ruby 3.3.1 (2024-04-23 revision c56cd86388) [x86_64-linux]
No response
Apologies for the delay here @kyori19!
I was able to replicate via tests (it looks like there was also a substantial gap in test coverage here), and will prioritize a fix shortly!
Is there an existing issue for this?
Is this a regression?
Current Behavior
association :parent, blueprint: ParentBlueprint, if: :include_parent?
inChildBlueprint
callsParentBlueprint.include_parent?
Expected Behavior
association :parent, blueprint: ParentBlueprint, if: :include_parent?
inChildBlueprint
should callChildBlueprint.include_parent?
Steps To Reproduce
Use this script to reproduce the problem.
Environment
Anything else?
No response