Class: UatActions

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
app/uat_actions/uat_actions.rb

Overview

Base class for Uat Actions Adding a new action: 1) rails generate uat_action MyNewAction –description=My action description

Author:

  • jg16

Defined Under Namespace

Modules: StaticRecords Classes: FormField, GeneratePlateConcentrations, GeneratePlates, GenerateTagGroup, GenerateTagPlates, IntergrationSuiteTools, TestSubmission

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.allObject


17
18
19
# File 'app/uat_actions/uat_actions.rb', line 17

def all
  uat_actions.values
end

.defaultObject


57
58
59
# File 'app/uat_actions/uat_actions.rb', line 57

def default
  new
end

.find(id) ⇒ Object


21
22
23
# File 'app/uat_actions/uat_actions.rb', line 21

def find(id)
  uat_actions[id]
end

.form_field(attribute, type, options = {}) ⇒ Object


43
44
45
46
47
# File 'app/uat_actions/uat_actions.rb', line 43

def form_field(attribute, type, options = {})
  @form_fields ||= []
  attr_accessor attribute
  @form_fields << UatActions::FormField.new(options.merge(attribute: attribute, type: type))
end

.form_fieldsObject


49
50
51
# File 'app/uat_actions/uat_actions.rb', line 49

def form_fields
  @form_fields || []
end

.idObject


39
40
41
# File 'app/uat_actions/uat_actions.rb', line 39

def id
  name.demodulize.parameterize
end

.inherited(other) ⇒ Object

Called by UatActions classes to register themselves


31
32
33
# File 'app/uat_actions/uat_actions.rb', line 31

def inherited(other)
  uat_actions[other.id] = other
end

.permittedObject


53
54
55
# File 'app/uat_actions/uat_actions.rb', line 53

def permitted
  form_fields.map(&:attribute)
end

.to_partial_pathObject


35
36
37
# File 'app/uat_actions/uat_actions.rb', line 35

def to_partial_path
  'uat_actions/entry'
end

.uat_actionsObject

The hash of all registered uat_actions


26
27
28
# File 'app/uat_actions/uat_actions.rb', line 26

def uat_actions
  @uat_actions ||= {}
end

Instance Method Details

#form_fieldsObject


66
67
68
# File 'app/uat_actions/uat_actions.rb', line 66

def form_fields
  self.class.form_fields
end

#performObject


74
75
76
77
# File 'app/uat_actions/uat_actions.rb', line 74

def perform
  errors.add(:base, 'This action has not been implemented.')
  false
end

#reportObject


62
63
64
# File 'app/uat_actions/uat_actions.rb', line 62

def report
  @report ||= {}
end

#saveObject


70
71
72
# File 'app/uat_actions/uat_actions.rb', line 70

def save
  valid? && ActiveRecord::Base.transaction { perform }
end