Class: LedgerSync::Type::Date

Inherits:
ActiveModel::Type::Date
  • Object
show all
Includes:
ValueMixin
Defined in:
lib/ledger_sync/type/date.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods included from ValueMixin

#assert_valid, #cast, included

Instance Method Details

#typeObject



10
11
12
# File 'lib/ledger_sync/type/date.rb', line 10

def type
  :date
end

#valid?(args = {}) ⇒ Boolean

Returns:



14
15
16
17
18
19
20
21
22
# File 'lib/ledger_sync/type/date.rb', line 14

def valid?(args = {})
  return false unless valid_class?(args)

  value = args.fetch(:value)
  return true unless value.is_a?(::String)
  return false unless value =~ /\A[0-9]{4}-[0-9]{2}-[0-9]{2}\z/

  true
end

#valid_classesObject



24
25
26
# File 'lib/ledger_sync/type/date.rb', line 24

def valid_classes
  [::Date, ::String]
end