Class: ActiveRecord::Bixformer::Compiler
- Inherits:
-
Object
- Object
- ActiveRecord::Bixformer::Compiler
- Defined in:
- lib/activerecord-bixformer/compiler.rb
Instance Method Summary collapse
- #clear ⇒ Object
- #compile ⇒ Object
-
#initialize(format, plan) ⇒ Compiler
constructor
A new instance of Compiler.
- #should_be_included ⇒ Object
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
#clear ⇒ Object
11 12 13 |
# File 'lib/activerecord-bixformer/compiler.rb', line 11 def clear @model = nil end |
#compile ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/activerecord-bixformer/compiler.rb', line 15 def compile @model ||= -> do model_type, = @plan.(@plan.value_of(:entry)[:type]) model = @plan.new_module_instance(:model, model_type, @model_name, ) compile_model(model) model end.call end |
#should_be_included ⇒ Object
27 28 29 |
# File 'lib/activerecord-bixformer/compiler.rb', line 27 def should_be_included compile.should_be_included end |