Class: Mongoid::Token::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/mongoid/token/options.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Options

Returns a new instance of Options.



2
3
4
# File 'lib/mongoid/token/options.rb', line 2

def initialize(options = {})
  @options = merge_defaults validate_options(options)
end

Instance Method Details

#containsObject



14
15
16
# File 'lib/mongoid/token/options.rb', line 14

def contains
  @options[:contains]
end

#field_nameObject



18
19
20
# File 'lib/mongoid/token/options.rb', line 18

def field_name
  @options[:field_name]
end

#lengthObject



6
7
8
# File 'lib/mongoid/token/options.rb', line 6

def length
  @options[:length]
end

#override_to_param?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/mongoid/token/options.rb', line 26

def override_to_param?
  @options[:override_to_param]
end

#patternObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/mongoid/token/options.rb', line 30

def pattern
  @options[:pattern] ||= case @options[:contains].to_sym
  when :alphanumeric
    "%s#{@options[:length]}"
  when :alpha
    "%w#{@options[:length]}"
  when :alpha_upper
    "%C#{@options[:length]}"
  when :alpha_lower
    "%c#{@options[:length]}"
  when :numeric
    "%d1,#{@options[:length]}"
  when :fixed_numeric
    "%d#{@options[:length]}"
  when :fixed_numeric_no_leading_zeros
    "%D#{@options[:length]}"
  end
end

#retry_countObject



10
11
12
# File 'lib/mongoid/token/options.rb', line 10

def retry_count
  @options[:retry_count]
end

#skip_finders?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/mongoid/token/options.rb', line 22

def skip_finders?
  @options[:skip_finders]
end