Class: LabwareCreators::Base

Inherits:
Object
  • Object
show all
Extended by:
NestedValidation
Includes:
Form, NoCustomPage, PlateWalking
Defined in:
app/models/labware_creators/base.rb

Overview

rubocop:todo Style/Documentation

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api, *args) ⇒ Base

We pull out the api as the first argument as it ensures we’ll always have it available, even during assignment of other attributes. Otherwise we end up relying on hash order.



38
39
40
41
# File 'app/models/labware_creators/base.rb', line 38

def initialize(api, *args)
  @api = api
  super(*args)
end

Instance Attribute Details

#apiObject (readonly)

Returns the value of attribute api.



16
17
18
# File 'app/models/labware_creators/base.rb', line 16

def api
  @api
end

#childObject (readonly)

Returns the value of attribute child.



16
17
18
# File 'app/models/labware_creators/base.rb', line 16

def child
  @child
end

#paramsObject

Returns the value of attribute params.



17
18
19
# File 'app/models/labware_creators/base.rb', line 17

def params
  @params
end

#parent_uuidObject

Returns the value of attribute parent_uuid.



17
18
19
# File 'app/models/labware_creators/base.rb', line 17

def parent_uuid
  @parent_uuid
end

#purpose_uuidObject

Returns the value of attribute purpose_uuid.



17
18
19
# File 'app/models/labware_creators/base.rb', line 17

def purpose_uuid
  @purpose_uuid
end

#user_uuidObject

Returns the value of attribute user_uuid.



17
18
19
# File 'app/models/labware_creators/base.rb', line 17

def user_uuid
  @user_uuid
end

Class Method Details

.support_parent?(_parent) ⇒ Boolean

The base creator is abstract, and is not intended to be used directly

Returns:

  • (Boolean)


31
32
33
# File 'app/models/labware_creators/base.rb', line 31

def self.support_parent?(_parent)
  false
end

.validates_nested(*attr_names) ⇒ NestedValidator Originally defined in module NestedValidation

Records of this class will call valid? on any associations provided as attr_names. Errors on these records will be propagated out

Parameters:

  • *attr_names (Symbol)

    One or more associations to validate

Returns:

Instance Method Details

#anchorObject



91
92
93
# File 'app/models/labware_creators/base.rb', line 91

def anchor
  'summary_tab'
end

#labwareObject



47
48
49
# File 'app/models/labware_creators/base.rb', line 47

def labware
  parent
end

#persisted?Boolean Originally defined in module Form

Returns:

  • (Boolean)

#plate_to_walkObject



43
44
45
# File 'app/models/labware_creators/base.rb', line 43

def plate_to_walk
  parent
end

#purpose_nameString

The name of the child purpose.

Returns:

  • (String)

    The purpose name



100
101
102
# File 'app/models/labware_creators/base.rb', line 100

def purpose_name
  purpose_config.name
end

#redirection_targetObject

The object which we cant to redirect the user to after the creator has been saved. If you’ve created a single entity, this should probably be the child, so that’s what we return by default

Returns:

  • (Object)

    Object that supports url_for(object)



87
88
89
# File 'app/models/labware_creators/base.rb', line 87

def redirection_target
  child
end

#saveObject



55
56
57
# File 'app/models/labware_creators/base.rb', line 55

def save
  valid? && create_labware!
end

#save!Object



51
52
53
# File 'app/models/labware_creators/base.rb', line 51

def save!
  save || raise(ResourceInvalid, self)
end

#transfer_template_name<String] The name of the transfer template which will be used.

The name of the transfer template which will be used. In post cases this will be the default transfer template but it can be overridden by specifying a custom template in the purpose config.

Returns:

  • (<String] The name of the transfer template which will be used.)

    <String] The name of the transfer template which will be used.



67
68
69
# File 'app/models/labware_creators/base.rb', line 67

def transfer_template_name
  purpose_config.fetch(:transfer_template, default_transfer_template_name)
end

#transfer_template_uuidString

The uuid of the transfer template to be used. Extracted from the transfer template cache base on the name

Returns:

  • (String)

    UUID



77
78
79
# File 'app/models/labware_creators/base.rb', line 77

def transfer_template_uuid
  Settings.transfer_templates.fetch(transfer_template_name)
end

#wells_by_rowObject Originally defined in module PlateWalking