Module: Auth::Concerns::Shopping::PersonalityConcern
- Extended by:
- ActiveSupport::Concern
- Includes:
- EsConcern, OwnerConcern, Mongoid::Autoinc
- Included in:
- Shopping::Personality
- Defined in:
- app/models/auth/concerns/shopping/personality_concern.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#add_info(tags) ⇒ Object
adds the name, sex, age in years, and the unique hash id for this personality.
-
#date_of_birth=(date_of_birth) ⇒ Object
date of birth is going to be a simple string.
- #set_autocomplete_description ⇒ Object
- #set_autocomplete_tags ⇒ Object
-
#set_primary_link ⇒ Object
AUTOCOMPLETE METHODS.
- #set_secondary_links ⇒ Object
-
#write_attribute(field, value) ⇒ Object
METHOD OVERRIDDEN BECAUSE MONGOID-AUTOINC, CALLS THIS METHOD TO SET THE VALUE OF THE AUTOINCREMENTING FIELD, AND WE NEEDED TO HOOK INTO THAT TO SET THE HASHID.
Instance Method Details
#add_info(tags) ⇒ Object
adds the name, sex, age in years, and the unique hash id for this personality
81 82 83 84 85 86 |
# File 'app/models/auth/concerns/shopping/personality_concern.rb', line 81 def add_info() << self.fullname << self.sex << ("Age: " + self.age.to_s + " years") << self.unique_hash_id end |
#date_of_birth=(date_of_birth) ⇒ Object
date of birth is going to be a simple string. format : YYYY-DD-MM, zero padded in case of single digits so this sets the age, now what.
91 92 93 94 95 96 97 98 |
# File 'app/models/auth/concerns/shopping/personality_concern.rb', line 91 def date_of_birth=(date_of_birth) super(date_of_birth) return unless date_of_birth birth_time = Time.parse(date_of_birth) self.age = ((Time.now - birth_time)/1.year).to_i end |
#set_autocomplete_description ⇒ Object
135 136 137 |
# File 'app/models/auth/concerns/shopping/personality_concern.rb', line 135 def set_autocomplete_description end |
#set_autocomplete_tags ⇒ Object
130 131 132 133 |
# File 'app/models/auth/concerns/shopping/personality_concern.rb', line 130 def self. = [] self. << "Personality" end |
#set_primary_link ⇒ Object
AUTOCOMPLETE METHODS.
108 109 110 |
# File 'app/models/auth/concerns/shopping/personality_concern.rb', line 108 def set_primary_link self.primary_link = Rails.application.routes.url_helpers.send(Auth::OmniAuth::Path.show_or_update_or_delete_path(Auth.configuration.personality_class),self.id.to_s) end |
#set_secondary_links ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'app/models/auth/concerns/shopping/personality_concern.rb', line 112 def set_secondary_links unless self.secondary_links["See All Carts"] end unless self.secondary_links["See Latest Cart"] end unless self.secondary_links["See Pending Carts"] end unless self.secondary_links["Edit Information"] end end |
#write_attribute(field, value) ⇒ Object
METHOD OVERRIDDEN BECAUSE MONGOID-AUTOINC, CALLS THIS METHOD TO SET THE VALUE OF THE AUTOINCREMENTING FIELD, AND WE NEEDED TO HOOK INTO THAT TO SET THE HASHID.
66 67 68 69 70 71 72 73 74 75 76 |
# File 'app/models/auth/concerns/shopping/personality_concern.rb', line 66 def write_attribute(field,value) super(field,value) if field.to_s == "auto_incrementing_number" if self.auto_incrementing_number_changed? unless self.unique_hash_id hashids = Hashids.new(Auth.configuration.hashids_salt,0,Auth.configuration.hashids_alphabet) self.unique_hash_id = hashids.encode(self.auto_incrementing_number) end end end end |