24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/generators/active_record/roles/roles_generator.rb', line 24
def apply_role_strategy
if logging?
require 'logging_assist'
self.class.send :include, Rails3::Assist::BasicLogger
logger.add_logfile :logfile => logfile if logfile
end
logger.debug "apply_role_strategy for : #{strategy} in model #{user_class}" if logging?
if !valid_strategy?
logger.error "Strategy '#{strategy}' is not valid, at least not for Active Record" if logging?
return
end
if !has_model? user_file
logger.error "Could not apply roles strategy to #{user_class} model since the model file was not found" if logging?
return
end
begin
logger.debug "Trying to insert roles code into #{user_class}" if logging?
insert_into_model user_file do
insertion_text
end
copy_role_models if roles_model_strategy?
rescue
logger.error "Error applying roles strategy to #{user_class}" if logging?
end
end
|