Class: OrderCompatibilityValidator::OrderRequestTypes

Inherits:
Object
  • Object
show all
Defined in:
app/validators/order_compatibility_validator.rb

Overview

A nifty little class to support the validation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ids = []) ⇒ OrderRequestTypes


28
29
30
31
# File 'app/validators/order_compatibility_validator.rb', line 28

def initialize(ids = [])
  @ids = ids
  @objects = RequestType.find(ids)
end

Instance Attribute Details

#idsObject (readonly)

Returns the value of attribute ids


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

def ids
  @ids
end

#objectsObject (readonly)

Returns the value of attribute objects


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

def objects
  @objects
end

Instance Method Details

#for_multiplexingObject


33
34
35
# File 'app/validators/order_compatibility_validator.rb', line 33

def for_multiplexing
  @for_multiplexing ||= objects.find(&:for_multiplexing?)
end

#for_multiplexing?Boolean


37
38
39
# File 'app/validators/order_compatibility_validator.rb', line 37

def for_multiplexing?
  for_multiplexing.present?
end

#not_for_multiplexing?Boolean


41
42
43
# File 'app/validators/order_compatibility_validator.rb', line 41

def not_for_multiplexing?
  for_multiplexing.blank?
end

#post_for_multiplexingObject


45
46
47
48
49
# File 'app/validators/order_compatibility_validator.rb', line 45

def post_for_multiplexing
  return unless for_multiplexing?

  ids.split(for_multiplexing.id).last
end