# frozen_string_literal: true module Upgrow # Defines attribute names to be set in a Model class. This allows pre-defining # a set of attributes to be set at once in a Model without having to declare # each one by hand. # # A Schema is a loose concept. This is just a convenience class to be used # when a more robust object is not present. In reality, any object that # responds to `attribute_names` can be used as a Schema. class Schema # Sets the Schema's attribute names. # # @param attribute_names [Array<Symbol>] the attribute names to be set. def initialize(*attribute_names) @attribute_names = Set.new(attribute_names) end # The list of attribute names for this Schema. # # @return [Array<Symbol>] the list of attribute names. def attribute_names @attribute_names.to_a end # Defines an attribute. # # @param name [Symbol] the name of the attribute. def attribute(name) @attribute_names += [name] end end end