Class: LedgerSync::Type::StringFromSet

Inherits:
String
  • Object
show all
Defined in:
lib/ledger_sync/type/string_from_set.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from String

#valid_classes

Methods included from ValueMixin

#cast, included

Constructor Details

#initialize(args = {}) ⇒ StringFromSet

Returns a new instance of StringFromSet.



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

def initialize(args = {})
  @values = args.fetch(:values)

  super(**args.except(:values))
end

Instance Attribute Details

#valuesObject (readonly)

Returns the value of attribute values.



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

def values
  @values
end

Instance Method Details

#assert_valid(args = {}) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/ledger_sync/type/string_from_set.rb', line 16

def assert_valid(args = {})
  return if valid_value?(args)

  raise Error::TypeError::StringFromSetError.new(
    expected: @values,
    given: args.fetch(:value)
  )
end

#typeObject



29
30
31
# File 'lib/ledger_sync/type/string_from_set.rb', line 29

def type
  :StringFromSet
end

#valid?(args = {}) ⇒ Boolean

Returns:



25
26
27
# File 'lib/ledger_sync/type/string_from_set.rb', line 25

def valid?(args = {})
  super && valid_value?(args)
end