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

Instantiate a section with default values even for multi: true sections #1210

Merged
merged 1 commit into from
Sep 19, 2016

Conversation

tagomoris
Copy link
Member

@tagomoris tagomoris commented Sep 7, 2016

Previously, "init: true, multi: false" sections were not instantiated (just [] for instance variable).
But with this behavior, we cannot use default values of these sections, except for the case to set a
blank Config::Element into conf.elements.
It looks abnormal, and non-useful feature for plugin authors.

So, this change will improve the situation.

Currently, there are some example without this fix:

config_section :parse do
  config_set_default :@type, "yay"
end

def configure(conf)
  super
  # ...
  @parser = parser_create(conf: conf.elements('parse').first, default_type: "yay")
end

This code has default type specification twice: config_set_default and default_type.
With this change:

config_section :parse do
  config_set_default :@type, "yay"
end

def configure(conf)
  super
  # ...
  @parser = parser_create(conf: conf.elements('parse').first)
end

Furthermore, this code works as you expected (for <parse> section without any argument).

config_section :parse do
  config_set_default :@type, "yay"
end

def configure(conf)
  super
  @parser = parser_create # default usage(argument) is ''
end

This looks better than ever.

…ing specified

Previously, "init: true, multi: false" sections were not instantiated (just `[]` for instance variable).
But with this behavior, we cannot use default values of these sections, except for the case to set a
blank Config::Element into `conf.elements`.
It looks abnormal, and non-useful feature for plugin authors.

So, this change will improve the situation.
@tagomoris
Copy link
Member Author

@repeatedly How do you think about this change?

@tagomoris tagomoris added enhancement Feature request or improve operations v0.14 labels Sep 13, 2016
@repeatedly
Copy link
Member

LGTM.

@repeatedly repeatedly merged commit cb5c312 into master Sep 19, 2016
@ganmacs ganmacs deleted the init-config-section-for-multi branch July 11, 2019 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature request or improve operations v0.14
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants