lib/backstack.rb in backstack-0.2.0 vs lib/backstack.rb in backstack-0.3.0
- old
+ new
@@ -54,15 +54,15 @@
# instance of AC could reach it, but this mysteriously breaks
# rails routing! So here are getters than we can use and access
# from the AC instance as self.class.get_bs_graph. RoR can be a
# real pit of dispair sometimes.
def get_bs_graph
- @bs_graph
+ @bs_graph || {}
end
def get_bs_labels
- @bs_labels
+ @bs_labels || {}
end
send :include, InstanceMethods
end
@@ -92,10 +92,11 @@
# Iterator to build breadcrumb trails
def backstack_trail
hashify = lambda{|x|
c, a = x[0].split /#/
- {:controller => c, :action => a, :fullpath => x[1], :label => x[2]}
+ label = x[2] || "#{a.capitalize}" # if forgot
+ {:controller => c, :action => a, :fullpath => x[1], :label => label}
}
if block_given?
session[:bs_stack].each { |x| yield hashify.call(x) }
else # return an array