Class: BeStrong::AttrAccessible

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

Class Method Summary collapse

Class Method Details

.remove(file) ⇒ Object



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

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

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

.remove_all(dir) ⇒ Object



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

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