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

Evaluate setting immediately if input defined #95

Merged
merged 1 commit into from Jun 22, 2020

Conversation

timriley
Copy link
Member

@timriley timriley commented Jun 19, 2020

This makes it possible for immediate feedback to be provided to users if an input is provided for a setting that has a constructor designed to raise errors when invalid input is provided.

I've checked this change against dry-{schema,validation,system} and they're all still green.

@timriley timriley force-pushed the evaluate-setting-if-input-defined branch from 39ae458 to 4b603a7 Compare June 22, 2020 11:53
@timriley timriley marked this pull request as ready for review June 22, 2020 11:56
@timriley timriley requested review from solnic and flash-gordon and removed request for solnic June 22, 2020 12:03
@timriley timriley force-pushed the evaluate-setting-if-input-defined branch from 4b603a7 to 679d2d7 Compare June 22, 2020 12:04
@timriley timriley merged commit 26bd017 into master Jun 22, 2020
@timriley timriley deleted the evaluate-setting-if-input-defined branch June 22, 2020 12:29
esparta added a commit to esparta/dry-configurable that referenced this pull request Aug 4, 2020
There's an corner case when a configuration should not be memoized
when using pre-processor values:

    MyMonitor = Class.new

    class Producer
      include Dry::Configurable
      setting(:monitor, false) { |monitor| monitor || MyMonitor.new }
    end

    p01 = Producer.new
    p02 = Producer.new

    raise 'Not memoized allowed'       if p01.config.monitor.object_id == p01.config.monitor.object_id

This behavior was introduced on Dry::Config 0.11.6, on PR dry-rb#95

Fixed dry-rb#96

Notes: I'm modifying the tests for Dry::Config::Setting because the test
was interfeiring with the behavior when introduce a constructor which
happend to be exactly the issue when using the setting method.
esparta added a commit to esparta/dry-configurable that referenced this pull request Aug 4, 2020
There's an corner case when a configuration should not be memoized
when using pre-processor values:

    MyMonitor = Class.new

    class Producer
      include Dry::Configurable
      setting(:monitor, false) { |monitor| monitor || MyMonitor.new }
    end

    p01 = Producer.new
    p02 = Producer.new

    raise 'Not memoized allowed'       if p01.config.monitor.object_id == p01.config.monitor.object_id

This behavior was introduced on Dry::Config 0.11.6, on PR dry-rb#95

Fixed dry-rb#96

Notes: I'm modifying the tests for Dry::Config::Setting because the test
was interfeiring with the behavior when introduce a constructor which
happend to be exactly the issue when using the setting method.
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

Successfully merging this pull request may close these issues.

None yet

2 participants