Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/blueprinter/extractors/block_extractor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Blueprinter
# @api private
class BlockExtractor < Extractor
def extract(_field_name, object, local_options, options = {})
options[:block].call(object, local_options)
options[:block].call(object, **local_options)
end
end
end
14 changes: 14 additions & 0 deletions spec/integrations/shared/base_render_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,20 @@ def self.if_method(_field_name, _object, _local_opts)
it('returns json with values derived from options') { should eq(result) }
end

context 'Given ::render with options with keyword field option' do
subject { blueprint.render(obj, vehicle: vehicle) }
let(:result) { '{"id":' + obj_id + ',"vehicle_make":"Super Car"}' }
let(:blueprint) do
Class.new(Blueprinter::Base) do
identifier :id
field :vehicle_make do |_obj, vehicle:, **|
"#{vehicle[:make]}"
end
end
end
it('returns json with values derived from options') { should eq(result) }
end

context 'Given ::render in a nested included view, original view is accessible in options' do
let(:blueprint) do
Class.new(Blueprinter::Base) do
Expand Down