Module: DeclareSchema::Macros

Defined in:
lib/declare_schema/extensions/active_record/fields_declaration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#_table_optionsObject (readonly)

Returns the value of attribute _table_options.



10
11
12
# File 'lib/declare_schema/extensions/active_record/fields_declaration.rb', line 10

def _table_options
  @_table_options
end

Instance Method Details

#declare_schema(default_schema: true, **table_options, &block) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/declare_schema/extensions/active_record/fields_declaration.rb', line 12

def declare_schema(default_schema: true, **table_options, &block)
  # Any model that calls 'fields' gets DeclareSchema::Model behavior
  DeclareSchema::Model.mix_in(self)

  # @include_in_migration = false #||= options.fetch(:include_in_migration, true); options.delete(:include_in_migration)
  @include_in_migration = true # TODO: Add back or delete the include_in_migration feature
  @_table_options        = table_options

  if block
    dsl = DeclareSchema::Dsl.new(self, null: false)
    dsl.instance_eval(&block)
    if default_schema && DeclareSchema.default_schema
      dsl.instance_exec(&DeclareSchema.default_schema)
    end
  end
end