Class: WorkingSet::ActiveRecordCompiler

Inherits:
Object
  • Object
show all
Defined in:
lib/working_set/active_record_compiler.rb

Instance Method Summary collapse

Constructor Details

#initialize(tree) ⇒ ActiveRecordCompiler

Returns a new instance of ActiveRecordCompiler.


3
4
5
# File 'lib/working_set/active_record_compiler.rb', line 3

def initialize(tree)
  @tree = tree
end

Instance Method Details

#compile(record, options = {}) ⇒ Object


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
# File 'lib/working_set/active_record_compiler.rb', line 7

def compile(record, options = {})
  # Set env if needed here...
  @tables = {}
  if variety = options[:variety] || options[:default]
    @tables[:variety] = variety
    @tables[:derivative_of] = variety
  end
  if derivative_of = options[:derivative_of] || options[:derivative] || options[:default]
    @tables[:derivative_of] = derivative_of
  end
  if abilities = options[:abilities] || options[:default]
    @tables[:abilities_list] = abilities
  end
  if indicators = options[:indicators] || options[:default]
    @tables[:frozen_indicators_list] = indicators
    @tables[:variable_indicators_list] = indicators
  end
  if indicators = options[:frozen_indicators] || options[:default]
    @tables[:frozen_indicators_list] = indicators
  end
  if indicators = options[:variable_indicators] || options[:default]
    @tables[:variable_indicators_list] = indicators
  end
  compute(@tree, record)
end