Module: HumanID::Migration

Included in:
ActiveRecord::ConnectionAdapters::TableDefinition
Defined in:
lib/humanid/migration.rb

Instance Method Summary collapse

Instance Method Details

#alias(*args) ⇒ Object

Commonly used



18
19
20
21
# File 'lib/humanid/migration.rb', line 18

def alias(*args)
  args << :alias if args.empty? || args.first.kind_of?(Hash)
  human_id(*args)
end

#human_id(*args) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/humanid/migration.rb', line 6

def human_id(*args)
  options         = args.extract_options!
  options[:index] = case options[:index]
    when true  then { unique: true }
    when false then false
    else            (options[:index] || {}).reverse_merge!(unique: true)
  end

  args.each { |name| column(name, :string, options) }
end