Class: ActiveInteractor::Type::Union
- Defined in:
- lib/active_interactor/type/union.rb
Instance Method Summary collapse
-
#initialize(*types) ⇒ Union
constructor
rubocop:disable Lint/MissingSuper.
- #valid?(value) ⇒ Boolean
Methods inherited from Base
Constructor Details
#initialize(*types) ⇒ Union
rubocop:disable Lint/MissingSuper
6 7 8 |
# File 'lib/active_interactor/type/union.rb', line 6 def initialize(*types) # rubocop:disable Lint/MissingSuper @valid_types = types end |
Instance Method Details
#valid?(value) ⇒ Boolean
10 11 12 13 14 15 16 |
# File 'lib/active_interactor/type/union.rb', line 10 def valid?(value) return true if value.nil? @valid_types.any? do |type| value_is_a_valid_active_interactor_type?(type, value) || value.is_a?(type) end end |