Module: Mongoid::Ids::ClassMethods

Defined in:
lib/mongoid/ids.rb

Instance Method Summary collapse

Instance Method Details

#token(*args) ⇒ Object

def initialize_copy(source)

super(source)
self.token = nil

end



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/mongoid/ids.rb', line 17

def token(*args)
  options = Mongoid::Ids::Options.new(args.extract_options!)
  options.field_name = args.join

  add_token_collision_resolver(options)

  if options.field_name == :_id
    self.field :_id, default: -> { generate_token(options.pattern) }
  else
    set_token_callbacks(options)
    add_token_field_and_index(options)

    define_custom_finders(options) if options.skip_finders? == false
  end
end