app/models/dc_user.rb in drg_cms-0.4.39 vs app/models/dc_user.rb in drg_cms-0.4.53

- old
+ new

@@ -19,11 +19,14 @@ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ -module DcUserCommon +######################################################################### +# ActiveSupport::Concern definition for DcUser class. +######################################################################### +module DcUserConcern extend ActiveSupport::Concern included do include Mongoid::Document include Mongoid::Timestamps @@ -75,17 +78,30 @@ validates_length_of :username, minimum: 4 before_save :do_before_save ########################################################################## +# before_save callback takes care of name field and ensures that e-mail is unique +# when entry is left empty. +########################################################################## def do_before_save self.name = "#{self.title} #{self.first_name} #{self.middle_name + ' ' unless self.middle_name.blank?}#{self.last_name}".strip # to ensure unique e-mail self.email = "unknown@#{self.id}" if self.email.to_s.strip.size < 5 end end end +######################################################################## +# Mongoid::Document model for dc_user documents. +# +# dc_users collection holds data about regitered users. Passwords are encrypted +# with bcrypt gem. +# +# This model defines basic fields required for evidence of +# registerred users. Since it is implemented as ActiveSupport::Concern you are +# encouraged to further expand model with your own data structures. +######################################################################## class DcUser - include DcUserCommon + include DcUserConcern end \ No newline at end of file