app/models/effective/code_writer.rb in effective_developer-0.2.12 vs app/models/effective/code_writer.rb in effective_developer-0.2.13

- old
+ new

@@ -21,9 +21,17 @@ write! end 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) + end + + # Returns true if the insert happened, nil if no insert def insert_after_last(content, depth: nil, content_depth: nil, &block) index = last(&block) return nil unless index insert(content, index, depth: depth, content_depth: content_depth)