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

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

Instance Method Summary collapse

Instance Method Details

#non_versioned_columnsObject



144
145
146
# File 'lib/cms/behaviors/versioning.rb', line 144

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



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

def version_class
  const_get "Version"
end

#version_class_nameObject



127
128
129
# File 'lib/cms/behaviors/versioning.rb', line 127

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.



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

def version_foreign_key
  :original_record_id
end

#version_table_nameObject



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

def version_table_name
  @version_table_name
end

#versioned_columnsObject



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

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