Module: Profileable::InstanceMethodsForProfileables

Defined in:
app/models/profileable.rb

Instance Method Summary collapse

Instance Method Details

#emailObject



31
32
33
# File 'app/models/profileable.rb', line 31

def email
  profile_fields_by_type( "ProfileFieldTypes::Email" ).first.value if profile_fields_by_type( "ProfileFieldTypes::Email" ).first
end

#email=(email) ⇒ Object



34
35
36
37
38
# File 'app/models/profileable.rb', line 34

def email=( email )
  @email_profile_field = profile_fields_by_type( "ProfileFieldTypes::Email" ).first unless @email_profile_field
  @email_profile_field = profile_fields.build( type: "ProfileFieldTypes::Email", label: "email" ) unless @email_profile_field
  @email_profile_field.value = email
end

#profileObject



40
41
42
# File 'app/models/profileable.rb', line 40

def profile
  @profile ||= Profile.new(self)
end

#profile_fields_by_type(type_or_types) ⇒ Object



52
53
54
# File 'app/models/profileable.rb', line 52

def profile_fields_by_type( type_or_types )
  profile_fields.where( type: type_or_types )
end

#profile_section_titlesObject



44
45
46
# File 'app/models/profileable.rb', line 44

def profile_section_titles
  self.class.profile_section_titles
end

#profile_sectionsObject



48
49
50
# File 'app/models/profileable.rb', line 48

def profile_sections
  self.profile.sections
end