Class: Lutaml::Model::ValuePolicy

Inherits:
Object
  • Object
show all
Defined in:
lib/lutaml/model/value_policy.rb

Overview

Decides how an attribute shapes incoming raw values: whether an Array is split element-wise (collection semantics) or handed whole to the declared type (value-owning semantics).

A user-defined Type::Value subclass may legitimately wrap lists or maps in a singular slot (#752); built-in scalar types keep the "collection: true is missing" guidance error.

Instance Method Summary collapse

Constructor Details

#initialize(collection:, union:, reference:) ⇒ ValuePolicy



13
14
15
16
17
# File 'lib/lutaml/model/value_policy.rb', line 13

def initialize(collection:, union:, reference:)
  @collection = collection
  @union = union
  @reference = reference
end

Instance Method Details

#whole_value?(type) ⇒ Boolean



21
22
23
24
# File 'lib/lutaml/model/value_policy.rb', line 21

def whole_value?(type)
  !@collection && !@union && !@reference &&
    type.is_a?(Class) && type < Type::Value && !Type.builtin?(type)
end