Sha256: 98f295e9b3a66dafef96e3e834e0b287a2d1f56382baa7497e4d979962384265
Contents?: true
Size: 793 Bytes
Versions: 11
Compression:
Stored size: 793 Bytes
Contents
# frozen_string_literal: true module Shark class SurveyParticipant < Base extend SurveyService::Resource has_one :survey, class_name: '::Shark::SurveyService::Survey' def self.table_name 'participants' end def self.find(*args) super.first end def self.create(attributes) attributes_copy = attributes.symbolize_keys survey_id = attributes_copy.delete(:survey_id) raise ArgumentError, 'Missing attribute :survey_id' unless survey_id participant = new(attributes_copy) participant.relationships.survey = { data: { id: survey_id } } participant.save participant end def participated? state == 'participated' end def participate update(state: 'participated') end end end
Version data entries
11 entries across 11 versions & 1 rubygems