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

Add type specific settings #341

Merged
merged 2 commits into from
Mar 1, 2016
Merged

Add type specific settings #341

merged 2 commits into from
Mar 1, 2016

Conversation

barthez
Copy link
Contributor

@barthez barthez commented Feb 26, 2016

As mentioned in #340 adding per type settings for import options would be a nice idea. It allows to tune batch size for each defined type specifically.

@pyromaniac What do you think about it?

@@ -47,6 +51,10 @@ def self.scopes
public_methods - Chewy::Type.public_methods
end

def self.settings(params)
self._settings = self._settings.deep_merge(params)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should params keys be restricted to "known settings"? Like:

KNOWN_SETTINGS = %i[import_options]

...
def self.settings(params)
  unknown_settings = params.each_key.select { |key| !KNOWN_OPTIONS.include?(key) }
  raise ArgumentError, "Unknown settings: #{unknown_settings.join(', ')}" unless unknown_settings.empty?
  self._settings = self._settings.deep_merge(params)
end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pyromaniac
Copy link
Contributor

I think settings name is too common, default_import_options maybe?

@barthez
Copy link
Contributor Author

barthez commented Feb 29, 2016

@pyromaniac Is it better now?

@pyromaniac
Copy link
Contributor

Yeah, much better, thanks!

pyromaniac added a commit that referenced this pull request Mar 1, 2016
@pyromaniac pyromaniac merged commit 44a4f97 into master Mar 1, 2016
@pyromaniac pyromaniac deleted the per-type-settings branch March 1, 2016 01:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants