Module: Superstore::ModelSchema::ClassMethods

Defined in:
lib/superstore/model_schema.rb

Instance Method Summary collapse

Instance Method Details

#attribute_namesObject



26
27
28
# File 'lib/superstore/model_schema.rb', line 26

def attribute_names
  attribute_types.keys
end

#attributes_builderObject

:nodoc:



10
11
12
# File 'lib/superstore/model_schema.rb', line 10

def attributes_builder # :nodoc:
  @attributes_builder ||= ActiveModel::AttributeSet::Builder.new(attribute_types, _default_attributes)
end

#column_namesObject



30
31
32
# File 'lib/superstore/model_schema.rb', line 30

def column_names
  attribute_names
end

#load_schema!Object

:nodoc:



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/superstore/model_schema.rb', line 14

def load_schema! # :nodoc:
  @columns_hash = {}

  attributes_to_define_after_schema_loads.each do |name, (type, options)|
    if type.is_a?(Symbol)
      type = ActiveRecord::Type.lookup(type, **options.except(:default))
    end

    define_attribute(name, type, **options.slice(:default))
  end
end