Project

General

Profile

« Previous | Next » 

Revision 13239

Added by Toshi MARUYAMA almost 11 years ago

graft trunk r13148 "not use cache for max rgt"

View differences:

sandbox/rails-4.1/lib/plugins/awesome_nested_set/lib/awesome_nested_set/model.rb
170 170
          nested_set_scope.column_names.map(&:to_s).include?(depth_column_name.to_s)
171 171
        end
172 172

  
173
        def right_most_node
174
          @right_most_node ||= self.class.base_class.unscoped.nested_set_scope(
175
            :order => "#{quoted_right_column_full_name} desc"
176
          ).first
177
        end
178

  
179 173
        def right_most_bound
180
          @right_most_bound ||= begin
181
            return 0 if right_most_node.nil?
182

  
183
            right_most_node.lock!
184
            right_most_node[right_column_name] || 0
185
          end
174
          right_most_node =
175
            self.class.base_class.unscoped.
176
              order("#{quoted_right_column_full_name} desc").limit(1).lock(true).first
177
          right_most_node ? (right_most_node[right_column_name] || 0 ) : 0
186 178
        end
187 179

  
188 180
        def set_depth!

Also available in: Unified diff