app/models/effective/code_writer.rb in effective_developer-0.4.3 vs app/models/effective/code_writer.rb in effective_developer-0.4.4
- old
+ new
@@ -28,9 +28,17 @@
write!
end
end
# Returns true if the insert happened, nil if no insert
+ def insert_into_first(content, &block)
+ index = first(&block)
+ return nil unless index
+
+ insert_raw(content, index, depth_at(index) + 1)
+ end
+
+ # Returns true if the insert happened, nil if no insert
def insert_after_first(content, depth: nil, content_depth: nil, &block)
index = first(&block)
return nil unless index
insert(content, index, depth: depth, content_depth: content_depth)