Sha256: 5c47d0ec49c0379c18e16ac6eb633daa7f27446dcd1ece0aa4e95e60ff6918b4

Contents?: true

Size: 395 Bytes

Versions: 155

Compression:

Stored size: 395 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
      end
    end.compact << attribute
  end
end

Version data entries

155 entries across 100 versions & 7 rubygems

Version Path
factory_girl-2.5.1 lib/factory_girl/aliases.rb
challah-0.3.0 vendor/bundle/gems/factory_girl-2.5.0/lib/factory_girl/aliases.rb
challah-0.2.1 vendor/bundle/gems/factory_girl-2.5.0/lib/factory_girl/aliases.rb
challah-0.2.0 vendor/bundle/gems/factory_girl-2.5.0/lib/factory_girl/aliases.rb
factory_girl-2.5.0 lib/factory_girl/aliases.rb
factory_girl-2.4.2 lib/factory_girl/aliases.rb
factory_girl-2.4.1 lib/factory_girl/aliases.rb
factory_girl-2.4.0 lib/factory_girl/aliases.rb
factory_girl-2.3.2 lib/factory_girl/aliases.rb
factory_girl-2.3.1 lib/factory_girl/aliases.rb
factory_girl-2.3.0 lib/factory_girl/aliases.rb
factory_girl-2.2.0 lib/factory_girl/aliases.rb
factory_girl-2.1.2 lib/factory_girl/aliases.rb
factory_girl-2.1.0 lib/factory_girl/aliases.rb
factory_girl-2.0.5 lib/factory_girl/aliases.rb