Sha256: dbdb4d607b500c01f8eec7a1939e8fa27385e6ddce738e7f51f89404d1150e61

Contents?: true

Size: 1.2 KB

Versions: 7

Compression:

Stored size: 1.2 KB

Contents

# These arms are part of the adolescent and adult projects
# Between 1 and 8 groups are in each arm and each group
# could have between 1 and 10 or so participants
class Arm < ActiveRecord::Base
  has_many :groups, dependent: :nullify
  has_many :bit_core_tools,
           class_name: "BitCore::Tool",
           foreign_key: :arm_id,
           dependent: :destroy
  has_many :bit_core_slideshows,
           class_name: "BitCore::Slideshow",
           foreign_key: :arm_id,
           dependent: :destroy

  validates :title, presence: true
  validates_with ArmValidator

  def display_name_required_for_membership?(participant, display_name)
    if social? && display_name.empty?
      participant.errors.add(
        :display_name, "is required because the arm of this \
          intervention utilizes social features or the \
          participant is currently enrolled in an arm that \
          requires a display name."
        )
      false
    else
      true
    end
  end

  def social?
    is_social
  end

  def woz?
    has_woz
  end

  def non_home_tools
    tools = BitCore::Tool.arel_table
    bit_core_tools
      .where(tools[:type].eq(nil)
        .or(tools[:type].not_eq("Tools::Home"))
      )
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
think_feel_do_engine-3.19.6 app/models/arm.rb
think_feel_do_engine-3.19.5 app/models/arm.rb
think_feel_do_engine-3.19.4 app/models/arm.rb
think_feel_do_engine-3.19.3 app/models/arm.rb
think_feel_do_engine-3.19.2 app/models/arm.rb
think_feel_do_engine-3.19.1 app/models/arm.rb
think_feel_do_engine-3.19.0 app/models/arm.rb