Sha256: a7f28475bd7973312efd7b674a27df02d804804a2a0d606a70f2a370987a2f18

Contents?: true

Size: 639 Bytes

Versions: 55

Compression:

Stored size: 639 Bytes

Contents

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

55 entries across 55 versions & 1 rubygems

Version Path
think_feel_do_engine-3.12.7 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.12.6 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.12.5 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.12.4 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.12.3 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.12.2 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.12.1 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.12.0 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.11.3 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.11.0 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.10.10 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.10.9 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.10.8 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.10.7 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.10.6 app/models/think_feel_do_engine/addressable.rb