class Upgrow::ModelSchema

The default Schema type for Basic Models. This is a specialized Schema that, in addition to attributes, supports the definition of associations.

Public Class Methods

new() click to toggle source

Sets the Model Schema's initial state, with an empty Set of association names.

Calls superclass method
# File lib/upgrow/model_schema.rb, line 9
def initialize
  super
  @association_names = Set.new
end

Public Instance Methods

association(name) click to toggle source

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.

# File lib/upgrow/model_schema.rb, line 20
def association(name)
  @association_names += [name]
end
association_names() click to toggle source

The list of association names for this Schema.

@return [Array<Symbol>] the list of association names.

# File lib/upgrow/model_schema.rb, line 27
def association_names
  @association_names.to_a
end