Class: RequestType::Validator::LibraryTypeValidator

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

Overview

rubocop:todo Style/Documentation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_type_id) ⇒ LibraryTypeValidator

Returns a new instance of LibraryTypeValidator.


12
13
14
# File 'app/models/request_type/validator.rb', line 12

def initialize(request_type_id)
  @request_type_id = request_type_id
end

Instance Attribute Details

#request_type_idObject (readonly)

Returns the value of attribute request_type_id.


10
11
12
# File 'app/models/request_type/validator.rb', line 10

def request_type_id
  @request_type_id
end

Instance Method Details

#defaultObject


24
25
26
# File 'app/models/request_type/validator.rb', line 24

def default
  request_type.default_library_type.try(:name)
end

#include?(option) ⇒ Boolean

Returns:

  • (Boolean)

20
21
22
# File 'app/models/request_type/validator.rb', line 20

def include?(option)
  request_type.library_types.where(name: option).pluck(:name).include?(option)
end

#request_typeObject


16
17
18
# File 'app/models/request_type/validator.rb', line 16

def request_type
  RequestType.find(request_type_id)
end

#to_aObject


28
29
30
# File 'app/models/request_type/validator.rb', line 28

def to_a
  request_type.library_types.map(&:name)
end