Class: Ezframe::PasswordType
Instance Attribute Summary
Attributes inherited from TypeBase
#attribute, #error, #parent
Instance Method Summary
collapse
Methods inherited from TextType
#db_type, #normalize, #value=
Methods inherited from TypeBase
#db_type, get_class, #key, #label, #multi_inputs?, #no_edit?, #no_view?, #normalize, #type, type_name, #use_view_format, #validate, #value, #value=, #view
Constructor Details
#initialize(attr = nil) ⇒ PasswordType
Returns a new instance of PasswordType.
278
279
280
281
|
# File 'lib/ezframe/column_type.rb', line 278
def initialize(attr = nil)
super(attr)
@attribute[:no_view] = true
end
|
Instance Method Details
302
303
304
305
|
# File 'lib/ezframe/column_type.rb', line 302
def db_value
crypt = BCrypt::Password.create(@value)
return crypt.to_s
end
|
#encrypt_value(val) ⇒ Object
283
284
285
286
|
# File 'lib/ezframe/column_type.rb', line 283
def encrypt_value(val)
crypt = BCrypt::Password.create(val)
return crypt.to_s
end
|
293
294
295
296
297
298
299
300
|
# File 'lib/ezframe/column_type.rb', line 293
def form(opts = {})
return nil if no_edit? && !opts[:force]
key = self.key
key ="#{key}#{opts[:key_suffix]}" if opts[:key_suffix]
h = { tag: "input", type: "password", name: key, label: @attribute[:label], value: "" }
h[:class] = @attribute[:class] if @attribute[:class]
return h
end
|
#value_equal?(value_from_db, new_value) ⇒ Boolean
288
289
290
291
|
# File 'lib/ezframe/column_type.rb', line 288
def value_equal?(value_from_db, new_value)
crypt = BCrypt::Password.new(value_from_db)
return crypt == new_value
end
|