Sha256: 1502a2a87a6432c9a4b1d8035b1f559728617317f7f086cf12b8bfbf65a9dd92

Contents?: true

Size: 940 Bytes

Versions: 8

Compression:

Stored size: 940 Bytes

Contents

module StudyEngine
  class UpdateAssessmentsForm
    extend ActiveModel::Naming

    def self.model_name
      ActiveModel::Name.new(Assessment)
    end

    def to_model
      self
    end

    def to_key
    end

    def to_param
      study_id.to_s
    end

    def persisted?
      true
    end

    def initialize study_id
      self.assessments = Assessment.by_study_id(study_id)
      self.study_id = StudyID.new(study_id)
    end

    attr_accessor :assessments, :study_id

    delegate :study, :site, :id, to: :study_id, prefix: true
    delegate :study=, :site=, :id=, to: :study_id, prefix: true

    def study_options
      StudyID::Bank.studies
    end

    def update_attributes! attributes
      attributes.each do |key, value|
        send "#{key}=", value
      end
      save
    end

    def save
      assessments.each do |assessment|
        assessment.update study_id: study_id
      end
      true
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
study_engine-0.3.1 app/models/study_engine/update_assessments_form.rb
study_engine-0.3.0 app/models/study_engine/update_assessments_form.rb
study_engine-0.2.2 app/models/study_engine/update_assessments_form.rb
study_engine-0.2.1 app/models/study_engine/update_assessments_form.rb
study_engine-0.2.0 app/models/study_engine/update_assessments_form.rb
study_engine-0.1.1 app/models/study_engine/update_assessments_form.rb
study_engine-0.1.0 app/models/study_engine/update_assessments_form.rb
study_engine-0.0.2 app/models/study_engine/update_assessments_form.rb