Module: Cms::Behaviors::Versioning::ClassMethods

Defined in:
lib/cms/behaviors/versioning.rb

Instance Method Summary collapse

Instance Method Details

#non_versioned_columnsObject



141
142
143
# File 'lib/cms/behaviors/versioning.rb', line 141

def non_versioned_columns
  (%w[  id lock_version position version_comment created_at updated_at created_by_id updated_by_id type original_record_id])
end

#version_classObject



120
121
122
# File 'lib/cms/behaviors/versioning.rb', line 120

def version_class
  const_get "Version"
end

#version_class_nameObject



124
125
126
# File 'lib/cms/behaviors/versioning.rb', line 124

def version_class_name
  "#{name}::Version"
end

#version_foreign_keyObject

Probably no longer needs to be a method anymore, since all classes use the same column name.



129
130
131
# File 'lib/cms/behaviors/versioning.rb', line 129

def version_foreign_key
  :original_record_id
end

#version_table_nameObject



133
134
135
# File 'lib/cms/behaviors/versioning.rb', line 133

def version_table_name
  @version_table_name
end

#versioned_columnsObject



137
138
139
# File 'lib/cms/behaviors/versioning.rb', line 137

def versioned_columns
  @versioned_columns ||= (version_class.new.attributes.keys - non_versioned_columns)
end