Class: Submission::PresenterSkeleton

Inherits:
Object
  • Object
show all
Defined in:
app/models/submission/presenter_skeleton.rb

Direct Known Subclasses

SubmissionCreator, SubmissionPresenter

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, submission_attributes = {}) ⇒ PresenterSkeleton


7
8
9
10
11
12
13
14
15
# File 'app/models/submission/presenter_skeleton.rb', line 7

def initialize(user, submission_attributes = {})
  submission_attributes = {} if submission_attributes.blank?

  @user = user

  attributes.each do |attribute|
    send("#{attribute}=", submission_attributes[attribute])
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object (protected)


37
38
39
40
41
42
43
44
45
# File 'app/models/submission/presenter_skeleton.rb', line 37

def method_missing(name, *args, &block)
  name_without_assignment = name.to_s.sub(/=$/, '').to_sym
  return super unless attributes.include?(name_without_assignment)

  instance_variable_name = :"@#{name_without_assignment}"
  return instance_variable_get(instance_variable_name) if name_without_assignment == name.to_sym

  instance_variable_set(instance_variable_name, args.first)
end

Instance Attribute Details

#idObject

id accessors need to be explicitly defined…


18
19
20
# File 'app/models/submission/presenter_skeleton.rb', line 18

def id
  @id
end

Instance Method Details

#cross_compatible?Boolean


28
29
# File 'app/models/submission/presenter_skeleton.rb', line 28

def cross_compatible?
end

#each_submission_warning(&block) ⇒ Object


31
32
33
# File 'app/models/submission/presenter_skeleton.rb', line 31

def each_submission_warning(&block)
  submission.each_submission_warning(&block)
end

#lanes_of_sequencingObject


22
23
24
25
26
# File 'app/models/submission/presenter_skeleton.rb', line 22

def lanes_of_sequencing
  return lanes_from_request_options if %{building pending}.include?(submission.state)

  lanes_from_request_counting
end