lib/gmaps4rails/extensions/array.rb in gmaps4rails-1.3.2 vs lib/gmaps4rails/extensions/array.rb in gmaps4rails-1.4.0
- old
+ new
@@ -1,12 +1,13 @@
class Array
#Scopes on models generate Arrays
#this method enables short call to the json creation for all elements in the array
def to_gmaps4rails(&block)
- json = "["
+ output = "["
+ json_array = []
each do |object|
- json << Gmaps4rails.create_json(object, &block).to_s
+ json_array << Gmaps4rails.create_json(object, &block).to_s
end
- json.chop!.chop! unless json == "["
- json << "]"
+ output << json_array * (",")
+ output << "]"
end
end
\ No newline at end of file