Module: TableStructure::Schema::ClassMethods

Defined in:
lib/table_structure/schema/class_methods.rb

Instance Method Summary collapse

Instance Method Details

#+(other) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/table_structure/schema/class_methods.rb', line 6

def +(other)
  raise ::TableStructure::Error, "Must be a schema class. [#{other}]" unless Utils.schema_class?(other)

  self_class = self

  Schema.create_class do
    columns self_class
    columns other
  end
end

#merge(*others) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/table_structure/schema/class_methods.rb', line 17

def merge(*others)
  others.each do |other|
    raise ::TableStructure::Error, "Must be a schema class. [#{other}]" unless Utils.schema_class?(other)
  end

  schema_class = CompositeClass.new.compose(self, *others)

  Schema.create_class do
    @__column_definitions__ = schema_class.column_definitions
    @__context_builders__ = schema_class.context_builders
    @__column_builders__ = schema_class.column_builders
    @__row_builders__ = schema_class.row_builders
  end
end