Class: TranslationCms::SyncAssetDestroyer

Inherits:
Object
  • Object
show all
Extended by:
ActiveModel::Naming
Includes:
ActiveModel::Conversion, ActiveModel::Validations
Defined in:
lib/translation_cms/sync_asset_destroyer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(asset, current_user) ⇒ SyncAssetDestroyer

Returns a new instance of SyncAssetDestroyer.



14
15
16
17
# File 'lib/translation_cms/sync_asset_destroyer.rb', line 14

def initialize(asset, current_user)
  @asset = asset
  @current_user = current_user
end

Instance Attribute Details

#assetObject (readonly)

Returns the value of attribute asset.



9
10
11
# File 'lib/translation_cms/sync_asset_destroyer.rb', line 9

def asset
  @asset
end

#current_userObject (readonly)

Returns the value of attribute current_user.



9
10
11
# File 'lib/translation_cms/sync_asset_destroyer.rb', line 9

def current_user
  @current_user
end

Instance Method Details

#performObject



19
20
21
22
23
24
25
26
27
# File 'lib/translation_cms/sync_asset_destroyer.rb', line 19

def perform
  return false unless valid?

  if asset.assetable?
    sync_delete_with_api
  else
    asset.destroy
  end
end