refact
This commit is contained in:
14
lib/service/message_service.rb
Normal file
14
lib/service/message_service.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class MessageService
|
||||
def initialize(repo) = @repo = repo
|
||||
|
||||
def recent(count = 30) = @repo.last(count)
|
||||
def count = @repo.count
|
||||
|
||||
def post(username, text)
|
||||
return :empty if text.strip.empty?
|
||||
@repo.append(username, text.strip[0...200])
|
||||
:ok
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user