Module: IntegerInheritance::Macro::ClassMethods

Defined in:
lib/integer-inheritance/macro.rb

Instance Method Summary collapse

Instance Method Details

#uses_integer_inheritance(options = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/integer-inheritance/macro.rb', line 9

def uses_integer_inheritance(options = {})
  include IntegerInheritance::Extension unless respond_to?(:inheritance_mapping)

  self.inheritance_column = options.fetch(:column, IntegerInheritance.default_column)

  # This is workaround for ActionDispatch::Reloader (in development environment)
  class_name = name
  mapping    = IntegerInheritance.mappings[class_name]
  self.inheritance_mapping = mapping if mapping
  IntegerInheritance.mappings[class_name] = self.inheritance_mapping
end