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

Returns a new instance of PresenterSkeleton.



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

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

  @user = user

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



34
35
36
37
38
39
40
41
42
# File 'app/models/submission/presenter_skeleton.rb', line 34

def method_missing(name, *args, &)
  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…



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

def id
  @id
end

Instance Method Details

#cross_compatible?Boolean

Returns:

  • (Boolean)


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

def cross_compatible?
end

#each_submission_warningObject



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

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

#lanes_of_sequencingObject



19
20
21
22
23
# File 'app/models/submission/presenter_skeleton.rb', line 19

def lanes_of_sequencing
  return lanes_from_request_options if 'building pending'.include?(submission.state)

  lanes_from_request_counting
end