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.



321
322
323
324
325
# File 'lib/redmine_extensions/patch_manager.rb', line 321

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.



318
319
320
# File 'lib/redmine_extensions/patch_manager.rb', line 318

def name
  @name
end

#orderObject

Returns the value of attribute order.



319
320
321
# File 'lib/redmine_extensions/patch_manager.rb', line 319

def order
  @order
end

#patchesObject (readonly)

Returns the value of attribute patches.



318
319
320
# File 'lib/redmine_extensions/patch_manager.rb', line 318

def patches
  @patches
end

Instance Method Details

#<<(ep) ⇒ Object

Raises:

  • (ArgumentError)


347
348
349
350
# File 'lib/redmine_extensions/patch_manager.rb', line 347

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

#<=>(other) ⇒ Object



352
353
354
# File 'lib/redmine_extensions/patch_manager.rb', line 352

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

#apply_all_patchesObject



329
330
331
332
333
# File 'lib/redmine_extensions/patch_manager.rb', line 329

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

#each(&block) ⇒ Object



335
336
337
338
339
340
341
342
343
344
345
# File 'lib/redmine_extensions/patch_manager.rb', line 335

def each(&block)

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

end