Sha256: e9743736dc63dfba8ff8171583aefec39f39c34206e81b6cbc6eecad6f5c26d8

Contents?: true

Size: 344 Bytes

Versions: 13

Compression:

Stored size: 344 Bytes

Contents

module FactoryBot
  class << self
    attr_accessor :aliases
  end

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

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

Version data entries

13 entries across 12 versions & 3 rubygems

Version Path
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.1.0/gems/factory_bot-6.5.0/lib/factory_bot/aliases.rb
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/factory_bot-6.5.0/lib/factory_bot/aliases.rb
factory_bot-6.5.0 lib/factory_bot/aliases.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/factory_bot-6.4.6/lib/factory_bot/aliases.rb
factory_bot-6.4.6 lib/factory_bot/aliases.rb
factory_bot-6.4.5 lib/factory_bot/aliases.rb
factory_bot-6.4.4 lib/factory_bot/aliases.rb
factory_bot-6.4.3 lib/factory_bot/aliases.rb
factory_bot-6.4.2 lib/factory_bot/aliases.rb
factory_bot-6.4.1 lib/factory_bot/aliases.rb
factory_bot-6.4.0 lib/factory_bot/aliases.rb
factory_bot-6.3.0 lib/factory_bot/aliases.rb
factory_bot-6.2.1 lib/factory_bot/aliases.rb