Class: ProfileSection
- Inherits:
-
Struct
- Object
- Struct
- ProfileSection
- Defined in:
- app/models/profile_section.rb
Instance Attribute Summary collapse
-
#profileable ⇒ Object
Returns the value of attribute profileable.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
- #field_types ⇒ Object
- #fields ⇒ Object
-
#initialize(options = {}) ⇒ ProfileSection
constructor
A new instance of ProfileSection.
- #profile_field_types ⇒ Object
- #profile_fields ⇒ Object
- #to_s ⇒ Object
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( = {} ) self.title = [:title] || raise('missing option "title"') self.profileable = [:profileable] || raise('missing option "profileable"') end |
Instance Attribute Details
#profileable ⇒ Object
Returns the value of attribute profileable
1 2 3 |
# File 'app/models/profile_section.rb', line 1 def profileable @profileable end |
#title ⇒ Object
Returns the value of attribute title
1 2 3 |
# File 'app/models/profile_section.rb', line 1 def title @title end |
Instance Method Details
#field_types ⇒ Object
41 42 43 |
# File 'app/models/profile_section.rb', line 41 def field_types profile_field_types end |
#fields ⇒ Object
11 12 13 |
# File 'app/models/profile_section.rb', line 11 def fields profile_fields end |
#profile_field_types ⇒ Object
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_fields ⇒ Object
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_s ⇒ Object
45 46 47 |
# File 'app/models/profile_section.rb', line 45 def to_s self.title.to_s end |