Sha256: 4261ab651d51aa537aae71400089cdc8b3529561a9777f7071bd021a95963df1
Contents?: true
Size: 947 Bytes
Versions: 4
Compression:
Stored size: 947 Bytes
Contents
# frozen_string_literal: true module Ad module AgentArchitecture module Dsl # This class is responsible for defining the attributes of a workflow class AttributeDsl < ChildDsl def attribute(name, type:, is_array: false) raise ArgumentError, 'Attribute name must be a string or symbol' unless name.is_a?(String) || name.is_a?(Symbol) workflow[:attributes][name] = { name: name, type: type, is_array: is_array } end def infer_attribute(name) raise ArgumentError, 'Attribute name must be a string or symbol' unless name.is_a?(String) || name.is_a?(Symbol) return if workflow[:attributes].key?(name) # May want to add more sophisticated type inference here type = name.to_s.end_with?('s') ? 'array' : 'string' workflow[:attributes][name] = { name: name, type: type, is_array: type == 'array' } end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems