Sha256: 89555ab0c84a6d5bcc32aba27dab47b01e11bf68ef4214584abd47663a653f85

Contents?: true

Size: 669 Bytes

Versions: 13

Compression:

Stored size: 669 Bytes

Contents

# frozen_string_literal: true
module ThinkFeelDoEngine
  # Labels the sender and recipient of a message.
  module Addressable
    def from(user = nil)
      if sender.id == user.try(:id)
        "You"
      elsif sender.try(:study_id)
        sender.study_id
      elsif recipient.try(:active_group).try(:arm).try(:has_woz?)
        "Moderator"
      else
        "Coach"
      end
    end

    def to(user = nil)
      if recipient.id == user.try(:id)
        "You"
      elsif recipient.try(:study_id)
        recipient.study_id
      elsif sender.try(:active_group).try(:arm).try(:has_woz?)
        "Moderator"
      else
        "Coach"
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
think_feel_do_engine-3.22.9 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.22.8 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.22.7 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.22.6 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.22.5 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.22.4 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.22.2 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.22.1 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.22.0 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.21.2 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.21.1 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.21.0 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.20.1 app/models/think_feel_do_engine/addressable.rb