Method: Ruber::PluginLike#remove_extensions_from_project

Defined in:
lib/ruber/plugin_like.rb

#remove_extensions_from_project(prj, all = true) ⇒ nil

Remove the extensions provided by the pluging from a project

Depending on the value of all, all the extensions provided by the plugin or only the ones which dont’ match the project are removed. In this case, a multi-class extension will only be removed if the class of the extension object is the same as the one specified in one of the entries which don’t match the project.

Note: to decide whether an extension belongs to the plugin or not, this method checks whether the object returned by the exension’s @plugin@ method is the same as @self@.

only those which don’t match the project

Parameters:

  • prj (Ruber::AbstractProject)

    the project to remove the extensions from

  • all (Boolean) (defaults to: true)

    whether to remove all extensions provided by the plugin or

Returns:

  • (nil)

See Also:



326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
# File 'lib/ruber/plugin_like.rb', line 326

def remove_extensions_from_project prj, all = true
  if all
    prj.each_extension.select{|_, v| v.plugin.same? self}.each do |k, _|
      emit removing_extension k.to_s, prj rescue nil
      prj.remove_extension k
      emit extension_removed k.to_s, prj rescue nil
    end
  else
    exts = @plugin_description.extensions
    prj.each_extension.select{|_, v| v.plugin.same? self}.each do |k, o|
      data = exts[k]
      data = data.find{|i| i.class_obj == o.class} if data.is_a? Array
      if !prj.match_rule? data
        emit removing_extension k.to_s, prj rescue nil
        prj.remove_extension k
        emit extension_removed k.to_s, prj rescue nil
      end
    end
  end
  nil
end