Sha256: 46270f2888d1ae0a9a95785fd0d2f4ba52720a0008c4e6cced8a4d855a435a58

Contents?: true

Size: 352 Bytes

Versions: 113

Compression:

Stored size: 352 Bytes

Contents

module FactoryGirl
  class << self
    attr_accessor :aliases
  end

  self.aliases = [
    [/(.+)_id/, '\1'],
    [/(.*)/, '\1_id']
  ]

  def self.aliases_for(attribute)
    aliases.map do |(pattern, replace)|
      if pattern.match(attribute.to_s)
        attribute.to_s.sub(pattern, replace).to_sym
      end
    end.compact << attribute
  end
end

Version data entries

113 entries across 100 versions & 12 rubygems

Version Path
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.3/vendor/bundle/gems/factory_girl-4.1.0/lib/factory_girl/aliases.rb
challah-rolls-0.2.0 vendor/bundle/gems/factory_girl-3.6.1/lib/factory_girl/aliases.rb
challah-rolls-0.2.0 vendor/bundle/gems/factory_girl-4.1.0/lib/factory_girl/aliases.rb
challah-0.8.3 vendor/bundle/gems/factory_girl-4.0.0/lib/factory_girl/aliases.rb
challah-0.8.3 vendor/bundle/gems/factory_girl-4.1.0/lib/factory_girl/aliases.rb
classiccms-0.6.8 vendor/bundle/gems/factory_girl-3.3.0/lib/factory_girl/aliases.rb
classiccms-0.6.7 vendor/bundle/gems/factory_girl-3.3.0/lib/factory_girl/aliases.rb
factory_girl-3.6.2 lib/factory_girl/aliases.rb
classiccms-0.6.6 vendor/bundle/gems/factory_girl-3.3.0/lib/factory_girl/aliases.rb
classiccms-0.6.5 vendor/bundle/gems/factory_girl-3.3.0/lib/factory_girl/aliases.rb
classiccms-0.6.4 vendor/bundle/gems/factory_girl-3.3.0/lib/factory_girl/aliases.rb
classiccms-0.6.3 vendor/bundle/gems/factory_girl-3.3.0/lib/factory_girl/aliases.rb
classiccms-0.6.2 vendor/bundle/gems/factory_girl-3.3.0/lib/factory_girl/aliases.rb
classiccms-0.6.1 vendor/bundle/gems/factory_girl-3.3.0/lib/factory_girl/aliases.rb
classiccms-0.6.0 vendor/bundle/gems/factory_girl-3.3.0/lib/factory_girl/aliases.rb
challah-0.8.1 vendor/bundle/gems/factory_girl-4.0.0/lib/factory_girl/aliases.rb
classiccms-0.5.17 vendor/bundle/gems/factory_girl-3.3.0/lib/factory_girl/aliases.rb
classiccms-0.5.16 vendor/bundle/gems/factory_girl-3.3.0/lib/factory_girl/aliases.rb
classiccms-0.5.15 vendor/bundle/gems/factory_girl-3.3.0/lib/factory_girl/aliases.rb
factory_girl-4.1.0 lib/factory_girl/aliases.rb