Method: Ruber::PluginLike#remove_options_from_project

Defined in:
lib/ruber/plugin_like.rb

#remove_options_from_project(prj, matching = true) ⇒ nil

Removes the project options provided by the plugin from a project

This method can operate in two ways: it can remove from the project all the options it provides whose rules match or don’t match the project. The first behaviour is meant to be used when the plugin is unloaded or the project is closed; the second when the project characteristics change, to remove those options which used to match the project but don’t anymore.

Parameters:

  • prj (Ruber::AbstractProject)

    the project to remove options from

  • matching (Boolean) (defaults to: true)

    whether to remove only

Returns:

  • (nil)

See Also:



221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# File 'lib/ruber/plugin_like.rb', line 221

def remove_options_from_project prj, matching = true
  if matching
    @plugin_description.project_options.each_pair do |_, o|
      o = o.to_os(prj.obj_binding)
      prj.remove_option o.group, o.name if prj.match_rule? o
    end
  else
    @plugin_description.project_options.each_pair do |_, o|
      o = o.to_os(prj.obj_binding)
      if prj.has_option?(o.group, o.name) and !prj.match_rule? o
        prj.remove_option o.group, o.name
      end
    end
  end
  nil
end