Class: Batches::StatusBatchesStatus

Inherits:
Object
  • Object
show all
Defined in:
lib/batches/models/status_batches_status.rb

Overview

Indicates where a batch is in its life cycle. *OPEN - Batch is open and can accept more transactions. *CLOSED - Batch is closed and cannot accept more transactions.

Constant Summary collapse

STATUS_BATCHES_STATUS =
[
  # TODO: Write general description for OPEN
  OPEN = 'OPEN'.freeze,

  # TODO: Write general description for CLOSED
  CLOSED = 'CLOSED'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = OPEN) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/batches/models/status_batches_status.rb', line 25

def self.from_value(value, default_value = OPEN)
  return default_value if value.nil?

  str = value.to_s.strip

  case str.downcase
  when 'open' then OPEN
  when 'closed' then CLOSED
  else
    default_value
  end
end

.validate(value) ⇒ Object



19
20
21
22
23
# File 'lib/batches/models/status_batches_status.rb', line 19

def self.validate(value)
  return false if value.nil?

  STATUS_BATCHES_STATUS.include?(value)
end