Class: ProfileSection

Inherits:
Struct
  • Object
show all
Defined in:
app/models/profile_section.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ ProfileSection

Returns a new instance of ProfileSection.



3
4
5
6
# File 'app/models/profile_section.rb', line 3

def initialize( options = {} )
  self.title = options[:title] || raise('missing option "title"')
  self.profileable = options[:profileable] || raise('missing option "profileable"')
end

Instance Attribute Details

#profileableObject

Returns the value of attribute profileable

Returns:

  • (Object)

    the current value of profileable



1
2
3
# File 'app/models/profile_section.rb', line 1

def profileable
  @profileable
end

#titleObject

Returns the value of attribute title

Returns:

  • (Object)

    the current value of title



1
2
3
# File 'app/models/profile_section.rb', line 1

def title
  @title
end

Instance Method Details

#field_typesObject



41
42
43
# File 'app/models/profile_section.rb', line 41

def field_types
  profile_field_types
end

#fieldsObject



11
12
13
# File 'app/models/profile_section.rb', line 11

def fields
  profile_fields
end

#profile_field_typesObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/models/profile_section.rb', line 15

def profile_field_types
  case(self.title.to_sym)
    when :general
      [ "ProfileFieldTypes::AcademicDegree", "ProfileFieldTypes::General" ]
    when :contact_information
      [ "ProfileFieldTypes::Address", "ProfileFieldTypes::Email", 
        "ProfileFieldTypes::Phone", "ProfileFieldTypes::Homepage", "ProfileFieldTypes::Custom" ]
    when :about_myself
      [ "ProfileFieldTypes::About" ]
    when :study_information
      [ "ProfileFieldTypes::Study" ]
    when :career_information
      [ "ProfileFieldTypes::Employment", "ProfileFieldTypes::ProfessionalCategory", "ProfileFieldTypes::Competence" ]
    when :organizations
      [ "ProfileFieldTypes::Organization" ]
    when :bank_account_information
      [ "ProfileFieldTypes::BankAccount" ]
    when :description
      [ "ProfileFieldTypes::Description" ]
    when :communication
      [ "ProfileFieldTypes::NameSurrounding" ]
    else
      []
  end
  
end

#profile_fieldsObject



8
9
10
# File 'app/models/profile_section.rb', line 8

def profile_fields
  profileable.profile_fields.where( type: self.profile_field_types )
end

#to_sObject



45
46
47
# File 'app/models/profile_section.rb', line 45

def to_s
  self.title.to_s
end