Class: LedgerSync::Type::ReferenceMany

Inherits:
Value
  • Object
show all
Includes:
ValueMixin
Defined in:
lib/ledger_sync/type/reference_many.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ValueMixin

#valid_classes

Constructor Details

#initialize(resource_class:) ⇒ ReferenceMany

Returns a new instance of ReferenceMany.



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

def initialize(resource_class:)
  @resource_class = resource_class
  super()
end

Instance Attribute Details

#resource_classObject (readonly)

Returns the value of attribute resource_class.



8
9
10
# File 'lib/ledger_sync/type/reference_many.rb', line 8

def resource_class
  @resource_class
end

Instance Method Details

#typeObject



15
16
17
# File 'lib/ledger_sync/type/reference_many.rb', line 15

def type
  :reference_many
end

#valid_without_casting?(value:) ⇒ Boolean

Returns:



19
20
21
22
23
24
# File 'lib/ledger_sync/type/reference_many.rb', line 19

def valid_without_casting?(value:)
  return false unless value.is_a?(Array)
  return true if value.reject { |e| e.is_a?(resource_class) }.empty?

  false
end