2010-06-24 09:45:57 -04:00
|
|
|
module FactoryGirl
|
2008-12-11 15:54:33 -05:00
|
|
|
class << self
|
2012-05-05 02:31:31 -04:00
|
|
|
attr_accessor :aliases
|
2008-12-11 15:54:33 -05:00
|
|
|
end
|
2011-08-13 01:03:12 -04:00
|
|
|
|
2008-07-30 15:47:12 -04:00
|
|
|
self.aliases = [
|
2010-07-26 07:15:22 -04:00
|
|
|
[/(.+)_id/, '\1'],
|
2008-07-30 15:47:12 -04:00
|
|
|
[/(.*)/, '\1_id']
|
|
|
|
]
|
|
|
|
|
2012-05-05 02:31:31 -04:00
|
|
|
def self.aliases_for(attribute)
|
2012-05-05 02:59:13 -04:00
|
|
|
aliases.map do |(pattern, replace)|
|
2008-07-30 15:47:12 -04:00
|
|
|
if pattern.match(attribute.to_s)
|
|
|
|
attribute.to_s.sub(pattern, replace).to_sym
|
|
|
|
end
|
|
|
|
end.compact << attribute
|
|
|
|
end
|
|
|
|
end
|