Skip to content

Commit

Permalink
Merge pull request Shopify#1656 from Shopify/uk-fix-store-accessor-in…
Browse files Browse the repository at this point in the history
…cludes

Pull module and include creation out of loop
  • Loading branch information
paracycle authored Sep 12, 2023
2 parents b580884 + d2d2f41 commit eb3c9b1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/tapioca/dsl/compilers/active_record_typed_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,17 @@ def decorate
return if stores.values.all? { |store| store.accessors.empty? }

root.create_path(constant) do |model|
store_accessors_module = model.create_module("StoreAccessors")
model.create_include("StoreAccessors")

stores.values.each do |store_data|
store_data.accessors.each do |accessor, name|
field = store_data.fields.fetch(accessor)
type = type_for(field.type_sym)
type = as_nilable_type(type) if field.null
name ||= field.name # support < 1.5.0

store_accessors_module = model.create_module("StoreAccessors")
generate_methods(store_accessors_module, name.to_s, type)
model.create_include("StoreAccessors")
end
end
end
Expand Down

0 comments on commit eb3c9b1

Please sign in to comment.