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

Returns a new instance of OrderRequestTypes.


30
31
32
33
# File 'app/validators/order_compatibility_validator.rb', line 30

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

Instance Attribute Details

#idsObject (readonly)

Returns the value of attribute ids


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

def ids
  @ids
end

#objectsObject (readonly)

Returns the value of attribute objects


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

def objects
  @objects
end

Instance Method Details

#for_multiplexingObject


35
36
37
# File 'app/validators/order_compatibility_validator.rb', line 35

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

#for_multiplexing?Boolean

Returns:

  • (Boolean)

39
40
41
# File 'app/validators/order_compatibility_validator.rb', line 39

def for_multiplexing?
  for_multiplexing.present?
end

#not_for_multiplexing?Boolean

Returns:

  • (Boolean)

43
44
45
# File 'app/validators/order_compatibility_validator.rb', line 43

def not_for_multiplexing?
  for_multiplexing.blank?
end

#post_for_multiplexingObject


47
48
49
50
51
# File 'app/validators/order_compatibility_validator.rb', line 47

def post_for_multiplexing
  return unless for_multiplexing?

  ids.split(for_multiplexing.id).last
end