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
classiccms-0.7.5 vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/aliases.rb
classiccms-0.7.5 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/aliases.rb
classiccms-0.7.4 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/aliases.rb
classiccms-0.7.4 vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/aliases.rb
classiccms-0.7.3 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/aliases.rb
classiccms-0.7.3 vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/aliases.rb
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/factory_girl-2.6.4/lib/factory_girl/aliases.rb
classiccms-0.7.2 vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/aliases.rb
classiccms-0.7.2 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/aliases.rb
classiccms-0.7.1 vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/aliases.rb
classiccms-0.7.1 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/aliases.rb
classiccms-0.7.0 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/aliases.rb
classiccms-0.7.0 vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/aliases.rb
classiccms-0.6.9 vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/aliases.rb
classiccms-0.6.9 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/aliases.rb
classiccms-0.6.8 vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/aliases.rb
classiccms-0.6.8 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/aliases.rb
classiccms-0.6.7 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/aliases.rb
classiccms-0.6.7 vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/aliases.rb
classiccms-0.6.6 vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/aliases.rb