Class: AocCli::Processors::ResourceAttacher

Inherits:
Core::Processor show all
Extended by:
Forwardable
Defined in:
lib/aoc_cli/processors/resource_attacher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Core::Processor

#run!, run!

Instance Attribute Details

#pathObject

Returns the value of attribute path.



6
7
8
# File 'lib/aoc_cli/processors/resource_attacher.rb', line 6

def path
  @path
end

#resourceObject

Returns the value of attribute resource.



6
7
8
# File 'lib/aoc_cli/processors/resource_attacher.rb', line 6

def resource
  @resource
end

Instance Method Details

#runObject



11
12
13
14
15
16
17
# File 'lib/aoc_cli/processors/resource_attacher.rb', line 11

def run
  if location.nil?
    Location.create(resource:, path:)
  else
    location&.update(path:) || location
  end.tap { resource.reload }
end