Class: Nandi::Renderers::ActiveRecord::Generate
- Inherits:
-
Cell::ViewModel
- Object
- Cell::ViewModel
- Nandi::Renderers::ActiveRecord::Generate
- Defined in:
- lib/nandi/renderers/active_record/generate.rb
Class Method Summary collapse
Instance Method Summary collapse
- #activerecord_version ⇒ Object
- #partials_base ⇒ Object
- #render_partial(instruction) ⇒ Object
- #should_disable_ddl_transaction? ⇒ Boolean
- #template_options_for(_options) ⇒ Object
Class Method Details
.call(*args) ⇒ Object
12 13 14 |
# File 'lib/nandi/renderers/active_record/generate.rb', line 12 def self.call(*args) super.call end |
Instance Method Details
#activerecord_version ⇒ Object
36 37 38 |
# File 'lib/nandi/renderers/active_record/generate.rb', line 36 def activerecord_version ::ActiveRecord::Migration.current_version end |
#partials_base ⇒ Object
16 17 18 |
# File 'lib/nandi/renderers/active_record/generate.rb', line 16 def partials_base "nandi/renderers/active_record/instructions" end |
#render_partial(instruction) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/nandi/renderers/active_record/generate.rb', line 40 def render_partial(instruction) if instruction.respond_to?(:template) cell(instruction.template, instruction) else cell("#{partials_base}/#{instruction.procedure}", instruction) end end |
#should_disable_ddl_transaction? ⇒ Boolean
31 32 33 34 |
# File 'lib/nandi/renderers/active_record/generate.rb', line 31 def should_disable_ddl_transaction? [*up_instructions, *down_instructions]. any? { |i| i.procedure.to_s.include?("index") } end |
#template_options_for(_options) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/nandi/renderers/active_record/generate.rb', line 20 def () { suffix: "rb.erb", template_class: Tilt, } end |