Module: BrighterPlanet::Emitter

Defined in:
lib/emitter.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#included(base) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/emitter.rb', line 3

def included(base)
  base.extend ClassMethods
  
  emitter_klass = self.to_s.split('::').last.underscore

  %w{carbon_model characterization data fallback relationships summarization}.each do |component|
    begin
      require "#{emitter_klass}/#{component}"
    rescue LoadError
    end
  end

  require 'leap'
  require 'cohort_scope'
  base.extend Leap::Subject
  base.send :include, const_get('CarbonModel')

  require 'characterizable'
  base.send :include, Characterizable
  base.send :include, const_get('Characterization')
  base.add_implicit_characteristics

  require 'data_miner'
  base.send :include, const_get('Data')

  if const_defined?('Fallback')
    require 'falls_back_on'
    require 'falls_back_on/active_record_ext'
    base.send :include, const_get('Fallback') 
  end

  if const_defined?('Relationships')
    base.send :include, const_get('Relationships')
  end

  require 'summary_judgement'
  base.extend SummaryJudgement
  base.send :include, const_get('Summarization')
end