Class: RedmineExtensions::PatchManager::EasyPatchesCollection

Inherits:
Object
  • Object
show all
Includes:
Comparable, Enumerable
Defined in:
lib/redmine_extensions/patch_manager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, order = nil) ⇒ EasyPatchesCollection

Returns a new instance of EasyPatchesCollection.



284
285
286
287
288
# File 'lib/redmine_extensions/patch_manager.rb', line 284

def initialize(name, order = nil)
  @name = name
  @patches = []
  @order = order || 0
end

Instance Attribute Details

#nameObject (readonly) Also known as: original_klass_to_patch

Returns the value of attribute name.



281
282
283
# File 'lib/redmine_extensions/patch_manager.rb', line 281

def name
  @name
end

#orderObject

Returns the value of attribute order.



282
283
284
# File 'lib/redmine_extensions/patch_manager.rb', line 282

def order
  @order
end

#patchesObject (readonly)

Returns the value of attribute patches.



281
282
283
# File 'lib/redmine_extensions/patch_manager.rb', line 281

def patches
  @patches
end

Instance Method Details

#<<(ep) ⇒ Object

Raises:

  • (ArgumentError)


310
311
312
313
# File 'lib/redmine_extensions/patch_manager.rb', line 310

def <<(ep)
  raise ArgumentError, 'patch class have to be a EasyPatch!' unless ep.is_a?(EasyPatch)
  @patches << ep
end

#<=>(other) ⇒ Object



315
316
317
# File 'lib/redmine_extensions/patch_manager.rb', line 315

def <=> other
  self.order <=> other.order
end

#apply_all_patchesObject



292
293
294
295
296
# File 'lib/redmine_extensions/patch_manager.rb', line 292

def apply_all_patches
  @patches.each do |ep|
    ep.apply_patch
  end
end

#each(&block) ⇒ Object



298
299
300
301
302
303
304
305
306
307
308
# File 'lib/redmine_extensions/patch_manager.rb', line 298

def each(&block)

  @patches.each do |patch|
    if block_given?
      block.call patch
    else
      yield patch
    end
  end

end