Module: ActiveRecordInclude::WhenConnected::ClassMethods

Defined in:
lib/active_record_include/when_connected.rb

Instance Method Summary collapse

Instance Method Details

#include_when_connected(mod, **options) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/active_record_include/when_connected.rb', line 8

def include_when_connected(mod, **options)
  self.class_eval do
    unless    defined?(modules_to_include_when_connected)
      class_attribute :modules_to_include_when_connected
    end
  end
  #puts %(#{self}.modules_to_include_when_connected=#{self.modules_to_include_when_connected.inspect})
  if options[:recursive] == false
    options[:into_classes] ||= [self]
  end
  self.modules_to_include_when_connected ||= []
  self.modules_to_include_when_connected  |= [{mod => options}]
  unless self < OnConnect
    include     OnConnect
  end
end