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

Nested namespaces #68

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

mistersourcerer
Copy link

This PR adds the ability to create a settings class with a nested namespace, so the "base hash" can be fetched from inside some yaml key.

  # /some/file/here.yml
  professional:
    preferences:
      order: desc
  client:
    prefs:
      order: asc

  class ProfessionalPreferences < Settingslogic
    source "/some/file/here.yml"
    namespace "professional.preferences"
  end
  >> ProfessionalPreferences.order
  => "desc"

… any hash.

you can pass a block to say what need to be done when a key isn't in the hash.
  # /some/file/here.yml
  professional:
    preferences:
      order: desc
  client:
    prefs:
      order: asc

  class ProfessionalPreferences < Settingslogic
    source "/some/file/here.yml"
    namespace "professional.preferences"
  end

  >> ProfessionalPreferences.order
  => "desc"
@zhouguangming
Copy link

+1

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.

2 participants