Module: ActiveShopifyGraphQL::Testing::AttributesHook
- Defined in:
- lib/active_shopify_graphql/testing/hook.rb
Overview
Prepended onto Attributes::ClassMethods so that attributes_for_loader returns attributes from ALL loader contexts when TestLoader is the requested loader. Without this, attributes defined only inside for_loader blocks (e.g. email on AdminApiLoader) would be invisible to the testing harness.
Instance Method Summary collapse
Instance Method Details
#attributes_for_loader(loader_class) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/active_shopify_graphql/testing/hook.rb', line 38 def attributes_for_loader(loader_class) if ActiveShopifyGraphQL::Testing.enabled? && loader_class == ActiveShopifyGraphQL::Testing::TestLoader base = instance_variable_get(:@base_attributes) || {} loader_contexts = instance_variable_get(:@loader_contexts) || {} merged = base.dup loader_contexts.each_value { |ctx_attrs| merged.merge!(ctx_attrs) { |_key, base_val, _override_val| base_val } } return merged end super end |