Sha256: f4fef8225cd4db25df5fc4a1fd7cbb814b7f55ddebd301143e922c99ebc0d882

Contents?: true

Size: 418 Bytes

Versions: 17

Compression:

Stored size: 418 Bytes

Contents

module FactoryGirl

  class << self
    attr_accessor :aliases #:nodoc:
  end
  self.aliases = [
    [/(.+)_id/, '\1'],
    [/(.*)/, '\1_id']
  ]

  def self.aliases_for(attribute) #:nodoc:
    aliases.collect do |params|
      pattern, replace = *params
      if pattern.match(attribute.to_s)
        attribute.to_s.sub(pattern, replace).to_sym
      else
        nil
      end
    end.compact << attribute
  end
end

Version data entries

17 entries across 17 versions & 3 rubygems

Version Path
factory_girl-2.0.4 lib/factory_girl/aliases.rb
factory_girl-2.0.3 lib/factory_girl/aliases.rb
factory_girl-2.0.2 lib/factory_girl/aliases.rb
factory_girl-2.0.1 lib/factory_girl/aliases.rb
factory_girl-2.0.0.rc4 lib/factory_girl/aliases.rb
factory_girl-2.0.0.rc3 lib/factory_girl/aliases.rb
factory_girl-2.0.0.rc2 lib/factory_girl/aliases.rb
factory_girl-2.0.0.rc1 lib/factory_girl/aliases.rb
factory_girl-2.0.0.beta5 lib/factory_girl/aliases.rb
factory_girl-2.0.0.beta4 lib/factory_girl/aliases.rb
factory_girl-2.0.0.beta3 lib/factory_girl/aliases.rb
factory_girl_kibiz0r-2.0.0.beta3 lib/factory_girl/aliases.rb
factory_girl_kibiz0r-2.0.0.beta2 lib/factory_girl/aliases.rb
factory_girl-2.0.0.beta2 lib/factory_girl/aliases.rb
vitalish-factory_girl-1.2.5 lib/factory_girl/aliases.rb
vitalish-factory_girl-1.2.4 lib/factory_girl/aliases.rb
factory_girl-2.0.0.beta1 lib/factory_girl/aliases.rb