Class: Profile
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Profile
- Includes:
- ActiveModel::ForbiddenAttributesProtection
- Defined in:
- app/models/profile.rb
Instance Method Summary collapse
- #age ⇒ Object
- #as_json(options = nil) ⇒ Object
- #birthday=(value) ⇒ Object
-
#contact_present? ⇒ Boolean
Returns true if the “Contact Information” section is empty.
-
#owner?(subject) ⇒ Boolean
Tells if the subject accessing the profile is its owner or not.
-
#personal_present? ⇒ Boolean
Returns true if the “Personal Information” section is empty.
-
#subject ⇒ Object
The subject of this profile.
-
#tags_present? ⇒ Boolean
True if the profile owner has tags attached.
Instance Method Details
#age ⇒ Object
44 45 46 47 48 |
# File 'app/models/profile.rb', line 44 def age return nil if self.birthday.blank? now = Time.now.utc.to_date now.year - self.birthday.year - (self.birthday.to_date.change(:year => now.year) > now ? 1 : 0) end |
#as_json(options = nil) ⇒ Object
83 84 85 86 87 88 89 |
# File 'app/models/profile.rb', line 83 def as_json = nil { nickName: slug, displayName: name, email: email, } end |
#birthday=(value) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/models/profile.rb', line 29 def birthday=(value) if value.blank? @birthday_formatted_invalid = false super value else begin #super Date.parse(value) super value @birthday_formatted_invalid = false rescue @birthday_formatted_invalid = true end end end |
#contact_present? ⇒ Boolean
Returns true if the “Contact Information” section is empty
70 71 72 73 74 75 76 |
# File 'app/models/profile.rb', line 70 def contact_present? phone? || mobile? || fax? || address? || website? end |
#owner?(subject) ⇒ Boolean
Tells if the subject accessing the profile is its owner or not
56 57 58 59 |
# File 'app/models/profile.rb', line 56 def owner?(subject) subject.present? && actor_id == Actor.normalize_id(subject) end |
#personal_present? ⇒ Boolean
Returns true if the “Personal Information” section is empty
62 63 64 65 66 67 |
# File 'app/models/profile.rb', line 62 def personal_present? organization? || birthday? || city? || description? end |
#subject ⇒ Object
The subject of this profile
51 52 53 |
# File 'app/models/profile.rb', line 51 def subject actor.try(:subject) end |
#tags_present? ⇒ Boolean
True if the profile owner has tags attached
79 80 81 |
# File 'app/models/profile.rb', line 79 def actor.tag_list.count > 0 end |