lib/lotus/utils/load_paths.rb in lotus-utils-0.5.2 vs lib/lotus/utils/load_paths.rb in lotus-utils-0.6.0
- old
+ new
@@ -16,11 +16,11 @@
# @since 0.2.0
#
# @see http://ruby-doc.org/stdlib/libdoc/pathname/rdoc/Pathname.html
# @see Lotus::Utils::Kernel.Pathname
def initialize(*paths)
- @paths = Array(paths)
+ @paths = Utils::Kernel.Array(paths)
end
# It specifies the policy for initialize copies of the object, when #clone
# or #dup are invoked.
#
@@ -59,11 +59,11 @@
#
# @raise [Errno::ENOENT] if one of the paths doesn't exist
#
# @since 0.2.0
def each
- Utils::Kernel.Array(@paths).each do |path|
+ @paths.each do |path|
yield realpath(path)
end
end
# Adds the given path(s).
@@ -109,10 +109,11 @@
#
# paths = Lotus::Utils::LoadPaths.new
# paths << '.' << '../..'
def push(*paths)
@paths.push(*paths)
+ @paths = Kernel.Array(@paths)
self
end
alias_method :<<, :push
@@ -133,9 +134,25 @@
# paths.push '.' # => RuntimeError
def freeze
super
@paths.freeze
end
+
+ # @since 0.6.0
+ # @api private
+ def ==(other)
+ case other
+ when self.class
+ other.paths == paths
+ else
+ other == paths
+ end
+ end
+
+ protected
+ # @since 0.6.0
+ # @api private
+ attr_reader :paths
private
# Allow subclasses to define their own policy to discover the realpath
# of the given path.
#