Class: RequestType::Validator::FlowcellTypeValidator

Inherits:
Object
  • Object
show all
Defined in:
app/models/request_type/validator.rb

Overview

Validates that the request type provided has a relation with a provided flowcell type name

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_type_key) ⇒ FlowcellTypeValidator

Returns a new instance of FlowcellTypeValidator.



39
40
41
# File 'app/models/request_type/validator.rb', line 39

def initialize(request_type_key)
  @request_type_key = request_type_key
end

Instance Attribute Details

#request_type_keyObject (readonly)

Returns the value of attribute request_type_key.



37
38
39
# File 'app/models/request_type/validator.rb', line 37

def request_type_key
  @request_type_key
end

Instance Method Details

#allow_blank?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'app/models/request_type/validator.rb', line 57

def allow_blank?
  true
end

#include?(option) ⇒ Boolean

Returns:

  • (Boolean)


47
48
49
50
# File 'app/models/request_type/validator.rb', line 47

def include?(option)
  return true if option.nil?
  request_type.flowcell_types.exists?(name: option)
end

#request_typeObject



43
44
45
# File 'app/models/request_type/validator.rb', line 43

def request_type
  RequestType.find_by(key: request_type_key)
end

#to_aObject



52
53
54
# File 'app/models/request_type/validator.rb', line 52

def to_a
  request_type.flowcell_types.pluck(:name).sort
end