Module: ActiveRecordInlineSchema::ActiveRecordClassMethods

Defined in:
lib/active_record_inline_schema/active_record_class_methods.rb

Constant Summary collapse

MUTEX =
::Mutex.new

Instance Method Summary collapse

Instance Method Details

#add_index(column_name, options = {}) ⇒ Object

this is not a typo - specify column name, not index name


20
21
22
# File 'lib/active_record_inline_schema/active_record_class_methods.rb', line 20

def add_index(column_name, options = {})
  inline_schema_config.add_ideal_index column_name, options
end

#auto_upgrade!(options = {}) ⇒ Object


24
25
26
# File 'lib/active_record_inline_schema/active_record_class_methods.rb', line 24

def auto_upgrade!(options = {})
  inline_schema_config.apply options
end

#col(column_name, options = {}) ⇒ Object


15
16
17
# File 'lib/active_record_inline_schema/active_record_class_methods.rb', line 15

def col(column_name, options = {})
  inline_schema_config.add_ideal_column column_name, options
end

#inline_schema_configObject


6
7
8
9
10
11
12
13
# File 'lib/active_record_inline_schema/active_record_class_methods.rb', line 6

def inline_schema_config
  if superclass != ::ActiveRecord::Base
    return base_class.inline_schema_config
  end
  @inline_schema_config || MUTEX.synchronize do
    @inline_schema_config ||= ::ActiveRecordInlineSchema::Config.new self
  end
end