Sha256: de0ab62159a83dfa9c55a611fb92bc5868e8fd7c3111904642b6996d2f9c50fe

Contents?: true

Size: 1.08 KB

Versions: 11

Compression:

Stored size: 1.08 KB

Contents

module SocialNetworking
  module Concerns
    # Collects data for feed/profiles page.
    module ShowFeed
      def feed_data_for(participant, context)
        @participant = participant
        @context = context

        {
          action_items: action_items,
          feed_items: [],
          member_profiles: member_profiles,
          profile_path: @context.social_networking_profile_path
        }
      end

      private

      def active_group
        @participant.active_group
      end

      def action_items
        items = ActionItem.for(@participant)
        current_profile = Profile.find_by_participant_id(@participant.id)
        unless current_profile.try(:started?)
          items.unshift(
            link: @context.social_networking_profile_path,
            label: "Create a Profile"
          )
        end

        items
      end

      def member_profiles
        return unless active_group
        Serializers::ProfileSerializer.from_collection(
          Profile.where(
            participant_id: active_group.active_participants.pluck(:id)))
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
social_networking-0.11.8 app/controllers/social_networking/concerns/show_feed.rb
social_networking-0.11.7 app/controllers/social_networking/concerns/show_feed.rb
social_networking-0.11.6 app/controllers/social_networking/concerns/show_feed.rb
social_networking-0.11.5 app/controllers/social_networking/concerns/show_feed.rb
social_networking-0.11.4 app/controllers/social_networking/concerns/show_feed.rb
social_networking-0.11.3 app/controllers/social_networking/concerns/show_feed.rb
social_networking-0.11.2 app/controllers/social_networking/concerns/show_feed.rb
social_networking-0.11.1 app/controllers/social_networking/concerns/show_feed.rb
social_networking-0.11.0 app/controllers/social_networking/concerns/show_feed.rb
social_networking-0.10.0 app/controllers/social_networking/concerns/show_feed.rb
social_networking-0.9.3 app/controllers/social_networking/concerns/show_feed.rb