Class: Pcrd::Schema::DiffEntry

Inherits:
Data
  • Object
show all
Defined in:
lib/pcrd/schema/diff_entry.rb

Overview

One row in a schema diff: describes the relationship between a source column and its counterpart on the target.

status values:

:unchanged       — column exists on both sides with the same name and type
:type_changed    — same name, different type
:renamed         — different name, same type
:type_and_renamed — different name AND different type
:dropped         — exists on source, absent from target (per spec)
:added           — absent from source, new column on target (per spec)

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#source_columnObject (readonly)

Returns the value of attribute source_column

Returns:

  • (Object)

    the current value of source_column



15
16
17
# File 'lib/pcrd/schema/diff_entry.rb', line 15

def source_column
  @source_column
end

#statusObject (readonly)

Returns the value of attribute status

Returns:

  • (Object)

    the current value of status



15
16
17
# File 'lib/pcrd/schema/diff_entry.rb', line 15

def status
  @status
end

#target_columnObject (readonly)

Returns the value of attribute target_column

Returns:

  • (Object)

    the current value of target_column



15
16
17
# File 'lib/pcrd/schema/diff_entry.rb', line 15

def target_column
  @target_column
end

Instance Method Details

#added?Boolean

Returns:

  • (Boolean)


22
# File 'lib/pcrd/schema/diff_entry.rb', line 22

def added?        = status == :added

#dropped?Boolean

Returns:

  • (Boolean)


21
# File 'lib/pcrd/schema/diff_entry.rb', line 21

def dropped?      = status == :dropped

#renamed?Boolean

Returns:

  • (Boolean)


20
# File 'lib/pcrd/schema/diff_entry.rb', line 20

def renamed?      = %i[renamed type_and_renamed].include?(status)

#source_nameObject



16
# File 'lib/pcrd/schema/diff_entry.rb', line 16

def source_name = source_column&.name

#status_labelObject



24
25
26
27
28
29
30
31
32
33
# File 'lib/pcrd/schema/diff_entry.rb', line 24

def status_label
  case status
  when :unchanged        then "unchanged"
  when :type_changed     then "type changed"
  when :renamed          then "renamed"
  when :type_and_renamed then "renamed + type changed"
  when :dropped          then "dropped"
  when :added            then "added"
  end
end

#target_nameObject



17
# File 'lib/pcrd/schema/diff_entry.rb', line 17

def target_name = target_column&.name

#type_changed?Boolean

Returns:

  • (Boolean)


19
# File 'lib/pcrd/schema/diff_entry.rb', line 19

def type_changed? = %i[type_changed type_and_renamed].include?(status)