Git Product home page Git Product logo

Comments (8)

solnic avatar solnic commented on June 12, 2024 1

Nesting shouldn't be supported as it makes no sense :)

from dry-configurable.

GustavoCaso avatar GustavoCaso commented on June 12, 2024 1

@AMHOL I think we can close this one

from dry-configurable.

artofhuman avatar artofhuman commented on June 12, 2024

What behavior for reader should be for this example?

class Foo 
  extend Dry::Configurable

  setting :database, reader: true do
    setting :dsn, 'sqlite:memory', reader: true
  end
end

from dry-configurable.

AMHOL avatar AMHOL commented on June 12, 2024

I'm not sure it would be necessary on nested settings as a reader on the root setting would make the child settings available as i.e. database.dsn

from dry-configurable.

AMHOL avatar AMHOL commented on June 12, 2024

Not sure about this as it introduces different behaviour based on the level of nesting, plus you could just use Forwardable and delegators to do the same

from dry-configurable.

solnic avatar solnic commented on June 12, 2024

@AMHOL wdym?

from dry-configurable.

timriley avatar timriley commented on June 12, 2024

@AMHOL's probably talking about what happens with something like this, for example?

setting :foo do
  setting :bar, reader: true
end

from dry-configurable.

AMHOL avatar AMHOL commented on June 12, 2024

@solnic I'm not sure the option should be supported though, the way the library works it can't be implemented on the root level without also being implemented at the nested level, and I'm not sure whether a library for configuration should support an option to expand the interface of an object. With Forwardable I meant something like:

class App
  extend Dry::Configurable

  class << self
    extend Forwardable
    def_delegator :config, :database
  end

  # Pass a block for nested configuration (works to any depth)
  setting :database do
    # Can pass a default value
    setting :dsn, 'sqlite:memory'
  end
  # Defaults to nil if no default value is given
  setting :adapter
end

App.database
=> #<struct dsn="sqlite:memory">

from dry-configurable.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.