Class: JenkinsApi::Client::PluginSettings::Collection
- Inherits:
-
Object
- Object
- JenkinsApi::Client::PluginSettings::Collection
- Extended by:
- Forwardable
- Defined in:
- lib/improved_jenkins_client/plugin_settings/collection.rb
Instance Method Summary collapse
- #add(plugin) ⇒ Object
- #configure(xml_doc) ⇒ Object
-
#initialize(*plugin_settings) ⇒ Collection
constructor
A new instance of Collection.
- #remove(plugin) ⇒ Object
Constructor Details
#initialize(*plugin_settings) ⇒ Collection
Returns a new instance of Collection.
11 12 13 14 |
# File 'lib/improved_jenkins_client/plugin_settings/collection.rb', line 11 def initialize(*plugin_settings) raise JenkinsApi::Client::PluginSettings::InvalidType unless plugin_settings.all? { |p| p.is_a?(JenkinsApi::Client::PluginSettings::Base) } @plugin_settings = plugin_settings end |
Instance Method Details
#add(plugin) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/improved_jenkins_client/plugin_settings/collection.rb', line 16 def add(plugin) raise JenkinsApi::Client::PluginSettings::InvalidType unless plugin.is_a?(JenkinsApi::Client::PluginSettings::Base) tap do |x| if @plugin_settings.none? { |p| p.class == plugin.class } @plugin_settings << plugin end end end |
#configure(xml_doc) ⇒ Object
31 32 33 34 35 |
# File 'lib/improved_jenkins_client/plugin_settings/collection.rb', line 31 def configure(xml_doc) xml_doc.tap do |x| @plugin_settings.each { |p| p.configure(x) } end end |
#remove(plugin) ⇒ Object
25 26 27 28 29 |
# File 'lib/improved_jenkins_client/plugin_settings/collection.rb', line 25 def remove(plugin) tap do |x| @plugin_settings.delete_if { |p| p.class == plugin.class } end end |