refact
This commit is contained in:
7
lib/service/games_service.rb
Normal file
7
lib/service/games_service.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class GamesService
|
||||
def initialize(repo) = @repo = repo
|
||||
|
||||
def all = @repo.fetch
|
||||
end
|
||||
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
|
||||
10
lib/service/online_service.rb
Normal file
10
lib/service/online_service.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class OnlineService
|
||||
def initialize(repo) = @repo = repo
|
||||
|
||||
def add(session_id, username) = @repo.add(session_id, username)
|
||||
def remove(session_id) = @repo.remove(session_id)
|
||||
def count = @repo.count
|
||||
def user_list = @repo.snapshot.sort.map { |_, name| name }
|
||||
end
|
||||
9
lib/service/wiki_service.rb
Normal file
9
lib/service/wiki_service.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class WikiService
|
||||
def initialize(repo) = @repo = repo
|
||||
|
||||
def list(category) = @repo.list(category)
|
||||
def content(page_id) = @repo.content(page_id)
|
||||
def page_url(locale, path) = @repo.page_url(locale, path)
|
||||
end
|
||||
Reference in New Issue
Block a user