move slice_collection optimization to utils

This commit is contained in:
Tom Burns
2013-11-24 14:00:23 -05:00
parent 2c26a880f0
commit e667352629
3 changed files with 17 additions and 10 deletions
+15 -4
View File
@@ -1,5 +1,20 @@
module Liquid
module Utils
def self.slice_collection(collection, from, to)
if (from != 0 || to != nil) && collection.respond_to?(:load_slice)
collection.load_slice(from, to)
else
slice_collection_using_each(collection, from, to)
end
end
def self.non_blank_string?(collection)
collection.is_a?(String) && collection != ''
end
private
def self.slice_collection_using_each(collection, from, to)
segments = []
index = 0
@@ -22,9 +37,5 @@ module Liquid
segments
end
def self.non_blank_string?(collection)
collection.is_a?(String) && collection != ''
end
end
end