Class: Mongoid::Ids::Options
- Inherits:
-
Object
- Object
- Mongoid::Ids::Options
- Defined in:
- lib/mongoid/ids/options.rb
Instance Method Summary collapse
- #contains ⇒ Object
- #field_name ⇒ Object
- #field_name=(param) ⇒ Object
-
#initialize(options = {}) ⇒ Options
constructor
A new instance of Options.
- #length ⇒ Object
- #pattern ⇒ Object
- #retry_count ⇒ Object
- #skip_finders? ⇒ Boolean
Constructor Details
#initialize(options = {}) ⇒ Options
Returns a new instance of Options.
4 5 6 |
# File 'lib/mongoid/ids/options.rb', line 4 def initialize( = {}) @options = merge_defaults () end |
Instance Method Details
#contains ⇒ Object
16 17 18 |
# File 'lib/mongoid/ids/options.rb', line 16 def contains @options[:contains] end |
#field_name ⇒ Object
20 21 22 |
# File 'lib/mongoid/ids/options.rb', line 20 def field_name @options[:field_name] end |
#field_name=(param) ⇒ Object
24 25 26 27 |
# File 'lib/mongoid/ids/options.rb', line 24 def field_name=(param) return if param.nil? || param.empty? @options[:field_name] = param end |
#length ⇒ Object
8 9 10 |
# File 'lib/mongoid/ids/options.rb', line 8 def length @options[:length] end |
#pattern ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/mongoid/ids/options.rb', line 33 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_count ⇒ Object
12 13 14 |
# File 'lib/mongoid/ids/options.rb', line 12 def retry_count @options[:retry_count] end |
#skip_finders? ⇒ Boolean
29 30 31 |
# File 'lib/mongoid/ids/options.rb', line 29 def skip_finders? @options[:skip_finders] end |