Class: Doggy::CLI::Edit
- Inherits:
-
Object
- Object
- Doggy::CLI::Edit
- Defined in:
- lib/doggy/cli/edit.rb
Instance Method Summary collapse
-
#initialize(options, param) ⇒ Edit
constructor
A new instance of Edit.
- #run ⇒ Object
Constructor Details
#initialize(options, param) ⇒ Edit
Returns a new instance of Edit.
6 7 8 9 |
# File 'lib/doggy/cli/edit.rb', line 6 def initialize(, param) @options = @param = param end |
Instance Method Details
#run ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/doggy/cli/edit.rb', line 11 def run resource = Doggy::Model.find_local(@param) return Doggy.ui.error("Could not find resource with #{@param}") unless resource forked_resource = fork(resource) system("open '#{forked_resource.human_edit_url}'") wait_for_edit new_resource = Doggy::Model.infer_type(resource.attributes).find(forked_resource.id) new_resource.id = resource.id if new_resource.is_a?(Doggy::Models::Dashboard) new_resource.title = resource.title new_resource.description = resource.description elsif new_resource.is_a?(Doggy::Models::Monitor) new_resource.name = resource.name elsif new_resource.is_a?(Doggy::Models::Screen) new_resource.board_title = resource.board_title end new_resource.path = resource.path new_resource.save_local forked_resource.destroy end |