class HecksApplication::Commands::Delete

Delete a resource.

Attributes

args[RW]
command_result[RW]
errors[RW]
repository[RW]

Public Class Methods

new(args: nil, repository:, domain_module:) click to toggle source
# File lib/commands/delete.rb, line 8
def initialize(args: nil, repository:, domain_module:)
  @args            = args || chained_command.args
  @repository      = repository
  @errors          = { base: [] }
end

Public Instance Methods

call() click to toggle source
# File lib/commands/delete.rb, line 14
def call
  delete
  self
end
name() click to toggle source
# File lib/commands/delete.rb, line 19
def name
  self.class.to_s.split('::').last.underscore
end
result() click to toggle source
# File lib/commands/delete.rb, line 27
def result
  { id: args[:id], errors: errors, args: args }
end
to_h() click to toggle source
# File lib/commands/delete.rb, line 23
def to_h
  { errors: errors, args: args }
end

Private Instance Methods

delete() click to toggle source
# File lib/commands/delete.rb, line 35
def delete
  @result = repository.delete(args[:id])
  @errors[:base] << "cound not find #{args[:id]}" unless @result
end