class HecksApplication::Commands::Update

Update a resource

Attributes

args[RW]
errors[R]
id[R]
repository[RW]
repository_result[R]

Public Class Methods

new(args: nil, repository: Repository, domain_module:) click to toggle source
# File lib/commands/update.rb, line 8
def initialize(args: nil, repository: Repository, domain_module:)
  @repository      = repository
  @args            = args
  @errors          = []
  @id              = @args.delete(:id)
end

Public Instance Methods

call() click to toggle source
# File lib/commands/update.rb, line 19
def call
  update
  self
end
name() click to toggle source
# File lib/commands/update.rb, line 15
def name
  self.class.to_s.split('::').last.underscore
end
result() click to toggle source
# File lib/commands/update.rb, line 24
def result
  { success: errors.empty?, errors: errors, args: args }
end
to_h() click to toggle source
# File lib/commands/update.rb, line 28
def to_h
  { id: id, args: args }
end

Private Instance Methods

update() click to toggle source
# File lib/commands/update.rb, line 36
def update
  return if @errors.count.positive?
  @repository_result = repository.update(id, args)
end