# frozen_string_literal: true module Upgrow # The default Schema type for Basic Models. This is a specialized Schema that, # in addition to attributes, supports the definition of associations. class ModelSchema < Schema # Sets the Model Schema's initial state, with an empty Set of association # names. def initialize super @association_names = Set.new end # Define a Model association. An association is a special type of attribute # that is optional upon initialization, but it raises an Association Not # Loaded error in case its reader is called when the attribute has not been # specified when the Model was instantiated. # # @param name [Symbol] the name of the association. def association(name) @association_names += [name] end # The list of association names for this Schema. # # @return [Array] the list of association names. def association_names @association_names.to_a end end end