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



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

def columns
  model.columns.map do |c|
    OpenStruct.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



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

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

#extra_args?Boolean

Returns:

  • (Boolean)


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

def extra_args?
  model.extra_args&.any?
end

#timestamps?Boolean

Returns:

  • (Boolean)


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

def timestamps?
  !model.timestamps_args.nil?
end

#timestamps_argsObject



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

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

#timestamps_args?Boolean

Returns:

  • (Boolean)


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

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