Class: RequestType::Validator::LibraryTypeValidator

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_type_id) ⇒ LibraryTypeValidator


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

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


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

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

#include?(option) ⇒ Boolean


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

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

#request_typeObject


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

def request_type
  RequestType.find(request_type_id)
end

#to_aObject


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

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