Sha256: 48879b501419adb88e1da55139888b8bb7924dbebb2531589ba052cbf2668de6
Contents?: true
Size: 523 Bytes
Versions: 5
Compression:
Stored size: 523 Bytes
Contents
require 'wlog/commands/commandable' require 'wlog/domain/log_entry' module Wlog # Command that replaces a string pattern found in an entry, with another string # @author Simon Symeonidis class ReplacePattern < Commandable def initialize(id, oldpat, newpat) @id, @oldpat, @newpat = id, oldpat, newpat end def execute log_entry = LogEntry.find(@id) log_entry.description = log_entry.description.gsub(/#{@oldpat}/, @newpat) log_entry.save rescue ActiveRecord::RecordNotFound false end end end
Version data entries
5 entries across 5 versions & 1 rubygems