Class: ActiveRecord::Bixformer::Compiler

Inherits:
Object
  • Object
show all
Defined in:
lib/activerecord-bixformer/compiler.rb

Direct Known Subclasses

From::Csv, To::Csv

Instance Method Summary collapse

Constructor Details

#initialize(format, plan) ⇒ Compiler

Returns a new instance of Compiler.



4
5
6
7
8
9
# File 'lib/activerecord-bixformer/compiler.rb', line 4

def initialize(format, plan)
  plan.__bixformer_format = format.to_s

  @model_name = plan.class.__bixformer_model
  @plan       = ActiveRecord::Bixformer::PlanAccessor.new(plan)
end

Instance Method Details

#compileObject



11
12
13
14
15
16
17
18
19
# File 'lib/activerecord-bixformer/compiler.rb', line 11

def compile
  model_type, model_options = @plan.parse_to_type_and_options(@plan.value_of(:entry)[:type])

  model = @plan.new_module_instance(:model, model_type, @model_name, model_options)

  compile_model(model)

  model
end