lib/key_tree/path.rb in key_tree-0.7.0 vs lib/key_tree/path.rb in key_tree-0.8.0
- old
+ new
@@ -26,20 +26,15 @@
# Make a new key path from a dot separated string, single symbol,
# or array of strings or symbols.
#
# Example:
# KeyTree::Path.new("a.b.c")
- # => ["a", "b", "c"]
+ # => [:a, :b, :c]
#
- def initialize(key_path = nil)
- case key_path
- when NilClass
- nil
- when Array
- concat(key_path.map(&:to_sym))
- else
- initialize(key_path.to_key_path)
- end
+ def initialize(key_path = [])
+ key_path = key_path.to_key_path unless key_path.is_a? Array
+
+ super(key_path.map(&:to_sym))
end
alias to_key_path itself
def to_s