Skip to content
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

ShopifyAPI::Rest::Base#initialize has a from_hash argument but subclasses override it out #1233

Closed
eni9889 opened this issue Oct 24, 2023 · 1 comment
Assignees

Comments

@eni9889
Copy link

eni9889 commented Oct 24, 2023

Issue summary

There's a seeminglyl useful from_hash: argument in ShopifyAPI::Rest::Base#initialize, but it's not usable because all subclasses override #initialize.

# base.rb
def initialize(session: nil, from_hash: nil)
   # elided code

  from_hash&.each do |key, value|
    set_property(key, value)
  end
end
# asset.rb
def initialize(session: ShopifyAPI::Context.active_session)
  super(session: session)
  # elided code
end

Expected behavior

Initialize a ShopifyAPI::Rest::* object with #new(from_hash: my_hash)

Actual behavior

ArgumentError: unknown keyword: :from_hash

Steps to reproduce the problem

Specifications

  • shopify_api version: 13.2.0
  • Shopify API version used: 2023-10):
@waruboy
Copy link

waruboy commented Nov 24, 2023

Up! this function is still featured quite prominently in the latest version of doc:

| `from_hash` | `Hash` | Default value is `nil`. Sets the resource properties to the values provided from the hash. |

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants