101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
# File 'lib/surveyor/survey_extensions.rb', line 101
def self.included(base)
base.class_eval do
def initialize_with_unique_access_code(obj, args, opts)
initialize_without_unique_access_code(obj, args, opts)
counter = 2
ac = self.access_code
original_ac = self.access_code
while( survey = ::Survey.find_by_access_code(ac) )
ac = [original_ac,"_",counter].join
counter += 1
end
self.access_code = ac
end
alias_method_chain :initialize, :unique_access_code
end
end
|