settingslogic icon indicating copy to clipboard operation
settingslogic copied to clipboard

Unused code in instance#method_missing?

Open leonelgalan opened this issue 12 years ago • 0 comments

https://github.com/binarylogic/settingslogic/blob/c510affe2e7ab96289525b95f50a5dd528854807/lib/settingslogic.rb#L113

  # 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.

leonelgalan avatar Nov 11 '13 16:11 leonelgalan