Class: Mongoid::Token::Options
- Inherits:
-
Object
- Object
- Mongoid::Token::Options
- Defined in:
- lib/mongoid/token/options.rb
Instance Method Summary collapse
- #contains ⇒ Object
- #field_name ⇒ Object
-
#initialize(options = {}) ⇒ Options
constructor
A new instance of Options.
- #length ⇒ Object
- #override_to_param? ⇒ Boolean
- #pattern ⇒ Object
- #retry_count ⇒ Object
- #skip_finders? ⇒ Boolean
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 = merge_defaults () end |
Instance Method Details
#contains ⇒ Object
14 15 16 |
# File 'lib/mongoid/token/options.rb', line 14 def contains @options[:contains] end |
#field_name ⇒ Object
18 19 20 |
# File 'lib/mongoid/token/options.rb', line 18 def field_name @options[:field_name] end |
#length ⇒ Object
6 7 8 |
# File 'lib/mongoid/token/options.rb', line 6 def length @options[:length] end |
#override_to_param? ⇒ Boolean
26 27 28 |
# File 'lib/mongoid/token/options.rb', line 26 def override_to_param? @options[:override_to_param] end |
#pattern ⇒ Object
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_count ⇒ Object
10 11 12 |
# File 'lib/mongoid/token/options.rb', line 10 def retry_count @options[:retry_count] end |
#skip_finders? ⇒ Boolean
22 23 24 |
# File 'lib/mongoid/token/options.rb', line 22 def skip_finders? @options[:skip_finders] end |