Class: Wlog::ConcatDescription

Inherits:
Commandable show all
Defined in:
lib/wlog/commands/concat_description.rb

Overview

Concatenate a string to an existing log entry

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, str) ⇒ ConcatDescription

Returns a new instance of ConcatDescription.



7
8
9
# File 'lib/wlog/commands/concat_description.rb', line 7

def initialize(id, str)
  @id, @str = id, str
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



20
21
22
# File 'lib/wlog/commands/concat_description.rb', line 20

def id
  @id
end

#strObject (readonly)

Returns the value of attribute str.



20
21
22
# File 'lib/wlog/commands/concat_description.rb', line 20

def str
  @str
end

Instance Method Details

#executeObject

Find and update the log entry



12
13
14
15
16
17
18
# File 'lib/wlog/commands/concat_description.rb', line 12

def execute
  log_entry = LogEntry.find(@id)
  log_entry.description += @str
  log_entry.save
rescue ActiveRecord::RecordNotFound
  false
end