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.19.9 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.19.8 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.19.7 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.19.6 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.19.5 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.19.4 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.19.3 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.19.2 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.19.1 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.19.0 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.18.0 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.17.2 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.17.1 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.17.0 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.16.3 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.16.2 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.16.1 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.15.7 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.16.0 app/models/think_feel_do_engine/addressable.rb
think_feel_do_engine-3.15.6 app/models/think_feel_do_engine/addressable.rb