Sha256: 34febc1f554d15e8514e32372d32bdb50620c91460c6174e48c9f7d0f1a41244
Contents?: true
Size: 1.65 KB
Versions: 4
Compression:
Stored size: 1.65 KB
Contents
# frozen_string_literal: true module SocialNetworking # A set of data representing a Social Profile belonging to a Participant. class Profile < ActiveRecord::Base ACTION_TYPES = %w( created completed ).freeze Actions = Struct.new(*ACTION_TYPES.map(&:to_sym)).new(*ACTION_TYPES) after_create :share_profile belongs_to :participant has_many :profile_answers, class_name: "SocialNetworking::ProfileAnswer", foreign_key: :social_networking_profile_id, dependent: :destroy has_many :comments, as: "item" has_many :likes, as: "item" validates :participant, presence: true validates :participant_id, uniqueness: true delegate :latest_action_at, :active_membership_end_date, to: :participant def self.icon_names %w( art bike bolt bookshelf die fashion flower genius heart helicopter hourglass keyboard magnifyingglass megaphone2 microphone music paintbrush2 plane polaroidcamera present recycle scooter shipwheel shoeprints star travelerbag ufo umbrella weather ) end def to_serialized {} end def started? profile_answers.any? end def description "Welcome, #{user_name}!" end def shared_description "Profile Created: #{participant.display_name}" end def user_name if participant.is_admin Rails.application.config.moderating_participant_display_name else participant.display_name end end private def share_profile SharedItem.create( item: self, action_type: Profile::Actions.created ) end end end
Version data entries
4 entries across 4 versions & 1 rubygems