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.


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

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


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

def request_type_id
  @request_type_id
end

Instance Method Details

#defaultObject


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

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

#include?(option) ⇒ Boolean

Returns:

  • (Boolean)

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

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

#request_typeObject


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

def request_type
  RequestType.find(request_type_id)
end

#to_aObject


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

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