lib/trestle/breadcrumb.rb in trestle-0.8.5 vs lib/trestle/breadcrumb.rb in trestle-0.8.6
- old
+ new
@@ -8,9 +8,22 @@
def ==(other)
label == other.label && path == other.path
end
+ def self.cast(obj)
+ case obj
+ when Breadcrumb
+ obj
+ when String
+ new(obj)
+ when Array
+ new(*obj)
+ else
+ raise ArgumentError, "Unable to cast #{obj.inspect} to Breadcrumb"
+ end
+ end
+
class Trail
include Enumerable
def initialize(breadcrumbs=[])
@breadcrumbs = Array(breadcrumbs)