Class: Lafcadio::PasswordField
- Inherits:
-
TextField
- Object
- ObjectField
- TextField
- Lafcadio::PasswordField
- Defined in:
- lib/lafcadio/objectField/PasswordField.rb
Overview
A PasswordField is simply a TextField that is expected to contain a password value. It can be set to auto-generate a password at random.
Instance Attribute Summary collapse
-
#autoGenerate ⇒ Object
Returns the value of attribute autoGenerate.
-
#maxLength ⇒ Object
readonly
Returns the value of attribute maxLength.
Attributes inherited from TextField
Attributes inherited from ObjectField
#dbFieldName, #default, #defaultFieldName, #hideDisplay, #hideLabel, #name, #notNull, #notUniqueMsg, #objectType, #unique, #writeOnce
Class Method Summary collapse
-
.randomPassword ⇒ Object
Returns a random 8-letter alphanumeric password.
Instance Method Summary collapse
-
#initialize(objectType, maxLength, name = "password", englishName = nil) ⇒ PasswordField
constructor
- objectType
-
The domain class that this object field belongs to.
Methods inherited from TextField
Methods inherited from ObjectField
#<=>, #bind_write?, #dbWillAutomaticallyWrite, #db_table_and_field_name, #englishName, #firstTime, instantiateFromXml, instantiateWithParameters, instantiationParameters, #nameForSQL, #nullErrorMsg, #prevValue, #processBeforeVerify, #valueForSQL, #valueFromSQL, valueType, #verify, #verifyUniqueness
Constructor Details
#initialize(objectType, maxLength, name = "password", englishName = nil) ⇒ PasswordField
- objectType
-
The domain class that this object field belongs to.
- name
-
The name of this field.
- maxLength
-
The maximum length of the password. (Deprecated)
- englishName
-
The descriptive English name of this field. (Deprecated)
23 24 25 26 27 |
# File 'lib/lafcadio/objectField/PasswordField.rb', line 23 def initialize(objectType, maxLength, name = "password", englishName = nil) super(objectType, name, englishName) @maxLength = maxLength @autoGenerate = true end |
Instance Attribute Details
#autoGenerate ⇒ Object
Returns the value of attribute autoGenerate.
17 18 19 |
# File 'lib/lafcadio/objectField/PasswordField.rb', line 17 def autoGenerate @autoGenerate end |
#maxLength ⇒ Object (readonly)
Returns the value of attribute maxLength.
16 17 18 |
# File 'lib/lafcadio/objectField/PasswordField.rb', line 16 def maxLength @maxLength end |
Class Method Details
.randomPassword ⇒ Object
Returns a random 8-letter alphanumeric password.
8 9 10 11 12 13 14 |
# File 'lib/lafcadio/objectField/PasswordField.rb', line 8 def PasswordField.randomPassword chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789". split(//) value = "" 0.upto(8) { |i| value += chars[rand(chars.size)] } value end |