Class: RedmineExtensions::PatchManager::EasyPatch

Inherits:
Object
  • Object
show all
Defined in:
lib/redmine_extensions/patch_manager.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(original_klass_to_patch, patching_module, options = {}) ⇒ EasyPatch

Returns a new instance of EasyPatch.



334
335
336
337
# File 'lib/redmine_extensions/patch_manager.rb', line 334

def initialize(original_klass_to_patch, patching_module, options = {})
  @original_klass_to_patch, @patching_module, @options = original_klass_to_patch, patching_module, options
  all_patching_modules << patching_module
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



332
333
334
# File 'lib/redmine_extensions/patch_manager.rb', line 332

def options
  @options
end

#original_klass_to_patchObject

Returns the value of attribute original_klass_to_patch.



332
333
334
# File 'lib/redmine_extensions/patch_manager.rb', line 332

def original_klass_to_patch
  @original_klass_to_patch
end

#patching_moduleObject

Returns the value of attribute patching_module.



332
333
334
# File 'lib/redmine_extensions/patch_manager.rb', line 332

def patching_module
  @patching_module
end

Class Method Details

.all_patching_modulesObject



324
325
326
# File 'lib/redmine_extensions/patch_manager.rb', line 324

def self.all_patching_modules
  @@all_patching_modules ||= []
end

Instance Method Details

#all_patching_modulesObject



328
329
330
# File 'lib/redmine_extensions/patch_manager.rb', line 328

def all_patching_modules
  self.class.all_patching_modules
end

#apply_patchObject



347
348
349
350
351
352
353
354
355
356
# File 'lib/redmine_extensions/patch_manager.rb', line 347

def apply_patch
  if (cond = @options.delete(:if)) && cond.respond_to?(:call)
    return unless cond.call
  end

  pm_klass = patching_module.constantize
  oktp_klass = original_klass_to_patch.constantize

  oktp_klass.send(:include, pm_klass) # unless oktp_klass.include?(pm_klass)
end

#inspectObject



343
344
345
# File 'lib/redmine_extensions/patch_manager.rb', line 343

def inspect
  to_s
end

#to_sObject



339
340
341
# File 'lib/redmine_extensions/patch_manager.rb', line 339

def to_s
  "#{@original_klass_to_patch} <= #{@patching_module}"
end