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

Unused code in instance#method_missing? #62

Open
leonelgalan opened this issue Nov 11, 2013 · 0 comments
Open

Unused code in instance#method_missing? #62

leonelgalan opened this issue Nov 11, 2013 · 0 comments

Comments

@leonelgalan
Copy link

# Called for dynamically-defined keys, and also the first key deferenced at the top-level, if load! is not used.

  # Called for dynamically-defined keys, and also the first key deferenced at the top-level, if load! is not used.
  # Otherwise, create_accessors! (called by new) will have created actual methods for each key.
  def method_missing(name, *args, &block)
    key = name.to_s
    return missing_key("Missing setting '#{key}' in #{@section}") unless has_key? key
    value = fetch(key)
    create_accessor_for(key)
    value.is_a?(Hash) ? self.class.new(value, "'#{key}' section in #{@section}") : value
  end

I notice the code after the return is not covered in tests and I wasn't able to hit it on my own. Anyway I tried, private method instance is called in the Settingslogic class, which creates accessors for fields that do exist, for keys that don't exist the method returns.

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

No branches or pull requests

1 participant