Class: BeStrong::StrongParameter

Inherits:
Object
  • Object
show all
Defined in:
lib/be_strong/strong_parameter.rb

Class Method Summary collapse

Class Method Details

.apply(file) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/be_strong/strong_parameter.rb', line 13

def apply(file)
  buf  = File.open(file, 'r'){|f| f.read}
  code = Code.new(buf).apply_strong_parameter!
  return false unless code.changed?

  File.open(file, 'w'){|f| f.puts(code.to_str)}
  true
end

.apply_all(dir) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/be_strong/strong_parameter.rb', line 4

def apply_all(dir)
  files = []
  Dir.glob(File.join(dir, '**/*.rb')).each do |file|
    applied = apply(file)
    files << file if applied
  end
  files
end