lib/liquid/utils.rb in locomotivecms-liquid-2.6.0 vs lib/liquid/utils.rb in locomotivecms-liquid-4.0.0.alpha

- old
+ new

@@ -1,7 +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 != ''.freeze + end + def self.slice_collection_using_each(collection, from, to) segments = [] index = 0 # Maintains Ruby 1.8.7 String#each behaviour on 1.9 @@ -19,12 +32,8 @@ index += 1 end segments - end - - def self.non_blank_string?(collection) - collection.is_a?(String) && collection != '' end end end