@@ -1617,15 +1617,23 @@ def define_login_field_methods
1617
1617
self . class . send ( :attr_reader , login_field ) unless respond_to? ( login_field )
1618
1618
end
1619
1619
1620
+ # @api private
1620
1621
def define_password_field_methods
1621
1622
return unless password_field
1622
- self . class . send ( :attr_writer , password_field ) unless respond_to? ( "#{ password_field } =" )
1623
- self . class . send ( :define_method , password_field ) { } unless respond_to? ( password_field )
1623
+ define_password_field_writer_method
1624
+ define_password_field_reader_methods
1625
+ end
1624
1626
1625
- # The password should not be accessible publicly. This way forms
1626
- # using form_for don't fill the password with the attempted
1627
- # password. To prevent this we just create this method that is
1628
- # private.
1627
+ # The password should not be accessible publicly. This way forms using
1628
+ # form_for don't fill the password with the attempted password. To prevent
1629
+ # this we just create this method that is private.
1630
+ #
1631
+ # @api private
1632
+ def define_password_field_reader_methods
1633
+ unless respond_to? ( password_field )
1634
+ # Deliberate no-op method, see rationale above.
1635
+ self . class . send ( :define_method , password_field ) { }
1636
+ end
1629
1637
self . class . class_eval (
1630
1638
<<-EOS , __FILE__ , __LINE__ + 1
1631
1639
private
@@ -1636,6 +1644,12 @@ def protected_#{password_field}
1636
1644
)
1637
1645
end
1638
1646
1647
+ def define_password_field_writer_method
1648
+ unless respond_to? ( "#{ password_field } =" )
1649
+ self . class . send ( :attr_writer , password_field )
1650
+ end
1651
+ end
1652
+
1639
1653
# Creating an alias method for the "record" method based on the klass
1640
1654
# name, so that we can do:
1641
1655
#
0 commit comments