Class: Nandi::Renderers::ActiveRecord::Instructions::CreateTableCell

Inherits:
Base
  • Object
show all
Defined in:
lib/nandi/renderers/active_record/instructions.rb

Instance Method Summary collapse

Methods inherited from Base

#template_options_for

Methods included from Formatting

#format_value, included

Instance Method Details

#columnsObject



61
62
63
64
65
66
67
68
69
70
# File 'lib/nandi/renderers/active_record/instructions.rb', line 61

def columns
  model.columns.map do |c|
    ::Nandi::Instructions::CreateTable::Column.new(
      name: format_value(c.name),
      type: format_value(c.type),
    ).tap do |col|
      col.args = format_value(c.args, as_argument: true) unless c.args.empty?
    end
  end
end

#extra_argsObject



57
58
59
# File 'lib/nandi/renderers/active_record/instructions.rb', line 57

def extra_args
  format_value(model.extra_args, as_argument: true)
end

#extra_args?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/nandi/renderers/active_record/instructions.rb', line 49

def extra_args?
  model.extra_args&.any?
end

#timestamps?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/nandi/renderers/active_record/instructions.rb', line 41

def timestamps?
  !model.timestamps_args.nil?
end

#timestamps_argsObject



53
54
55
# File 'lib/nandi/renderers/active_record/instructions.rb', line 53

def timestamps_args
  format_value(model.timestamps_args, as_argument: true)
end

#timestamps_args?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/nandi/renderers/active_record/instructions.rb', line 45

def timestamps_args?
  !model.timestamps_args&.empty?
end