Initial commit
This commit is contained in:
12
app/commands/posts/create_bookmark.rb
Normal file
12
app/commands/posts/create_bookmark.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
module Adamantium
|
||||
module Commands
|
||||
module Posts
|
||||
class CreateBookmark < Command
|
||||
include Deps["repos.post_repo"]
|
||||
def call(bookmark)
|
||||
post_repo.create(bookmark)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
18
app/commands/posts/create_entry.rb
Normal file
18
app/commands/posts/create_entry.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
module Adamantium
|
||||
module Commands
|
||||
module Posts
|
||||
class CreateEntry < Command
|
||||
include Deps["repos.post_repo",
|
||||
"post_utilities.slugify",
|
||||
renderer: "renderers.markdown"
|
||||
]
|
||||
def call(post)
|
||||
attrs = post.to_h
|
||||
attrs[:content] = renderer.call(content: attrs[:content])
|
||||
|
||||
post_repo.create(attrs)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
23
app/commands/posts/creation_resolver.rb
Normal file
23
app/commands/posts/creation_resolver.rb
Normal file
@@ -0,0 +1,23 @@
|
||||
module Adamantium
|
||||
module Commands
|
||||
module Posts
|
||||
class CreationResolver
|
||||
include Deps[
|
||||
"validation.posts.post_contract",
|
||||
"validation.posts.bookmark_contract",
|
||||
"commands.posts.create_entry",
|
||||
"commands.posts.create_bookmark"
|
||||
]
|
||||
|
||||
def call(entry_type:)
|
||||
case entry_type
|
||||
in Entities::BookmarkRequest
|
||||
{command: create_bookmark, validation: bookmark_contract}
|
||||
else
|
||||
{command: create_entry, validation: post_contract}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
14
app/commands/posts/delete.rb
Normal file
14
app/commands/posts/delete.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
module Adamantium
|
||||
module Commands
|
||||
module Posts
|
||||
class Delete < Command
|
||||
include Deps["repos.post_repo"]
|
||||
def call(params:)
|
||||
slug = URI(params[:url]).path.split("/").last
|
||||
|
||||
post_repo.delete!(slug)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
14
app/commands/posts/undelete.rb
Normal file
14
app/commands/posts/undelete.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
module Adamantium
|
||||
module Commands
|
||||
module Posts
|
||||
class Undelete < Command
|
||||
include Deps["repos.post_repo"]
|
||||
def call(params:)
|
||||
slug = URI(params[:url]).path.split("/").last
|
||||
|
||||
post_repo.restore!(slug)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
13
app/commands/posts/update.rb
Normal file
13
app/commands/posts/update.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
module Adamantium
|
||||
module Commands
|
||||
module Posts
|
||||
class Update < Command
|
||||
def call(params)
|
||||
slug = URI(params[:url]).path.split("/").last
|
||||
|
||||
post_repo.update(slug, params)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user