Module: FileMutate

Defined in:
lib/file_mutation.rb,
lib/file_mutate/delete.rb,
lib/file_mutate/mutate.rb,
lib/file_mutate/append_content.rb,
lib/file_mutate/insert_content.rb,
lib/file_mutate/remove_content.rb,
lib/file_mutate/replace_content.rb,
lib/file_mutate/overwrite_content.rb

Defined Under Namespace

Modules: AppendContent, Delete, InsertContent, Mutate, OverwriteContent, RemoveContent, ReplaceContent

Class Method Summary collapse

Class Method Details

.add_all(clazz) ⇒ Object



30
31
32
# File 'lib/file_mutation.rb', line 30

def self.add_all clazz
  add_mutate_exts clazz, mutate_apis
end

.add_mutate_exts(clazz, *names) ⇒ Object

Raises:

  • (ArgumentError)


34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/file_mutation.rb', line 34

def self.add_mutate_exts clazz, *names
  names.flat_uniq!
  unknowns = (names - mutate_apis)
  raise ArgumentError, "Unknown FileMutate APIs: #{unknowns}, must be one of: #{mutate_apis}" if !unknowns.empty?
  names.each do |api|
    ns = "FileMutate::#{api.to_s.camelize}"
    begin
      clazz.send :include, ns.constantize
      clazz.extend "#{ns}::ClassMethods".constantize
    end
  end
end

.mutate_apisObject



26
27
28
# File 'lib/file_mutation.rb', line 26

def self.mutate_apis
  [:delete, :mutate, :append_content, :insert_content, :overwrite_content, :remove_content, :replace_content]
end