Module: Fera::HasManySubmissions
- Extended by:
- ActiveSupport::Concern
- Included in:
- Customer
- Defined in:
- lib/fera/models/concerns/has_many_submissions.rb
Instance Method Summary collapse
Instance Method Details
#submissions(query = {}) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/fera/models/concerns/has_many_submissions.rb', line 22 def submissions(query = {}) if @submissions && query.blank? @submissions.to_a else Submission.where(query.merge("#{ self.class.name.demodulize.underscore }_id" => id)) end end |
#submissions=(new_submissions) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/fera/models/concerns/has_many_submissions.rb', line 11 def submissions=(new_submissions) @submissions = new_submissions.to_a.map do |model| if model.is_a?(Submission) model else model_id = model.try(:with_indifferent_access).try(:[], :id) Submission.new(model, model_id.present?) end end end |