lib/dcmgr/models/base_new.rb in wakame-vdc-agents-11.06.0 vs lib/dcmgr/models/base_new.rb in wakame-vdc-agents-11.12.0

- old
+ new

@@ -129,12 +129,18 @@ tag.unlabel(self.canonical_uuid) end def to_hash() - self.values.dup.merge({:id=>canonical_uuid, :uuid=>canonical_uuid}) + self.values.dup.merge({:id=>self.id, :uuid=>canonical_uuid}) end + + # generate API response document. similar to to_hash() but not + # to expose integer primary key. + def to_api_document + self.values.dup.merge({:id=>self.canonical_uuid, :uuid=>canonical_uuid}) + end end module ClassMethods # Getter and setter for uuid_prefix of the class. # @@ -184,11 +190,11 @@ raise InvalidUUIDError, "Invalid uuid or unsupported uuid: #{p_uuid} in #{self}" end # Checks the general uuid syntax def check_trimmed_uuid_format(uuid) - uuid.match(/^[a-z0-9 ]*$/) && uuid.length <= 8 + uuid.match(/^[a-z0-9]*$/) && uuid.length <= 255 end # Checks the uuid syntax if it is for the Taggable class. def check_uuid_format(uuid) uuid =~ /^#{self.uuid_prefix}-/ @@ -396,10 +402,14 @@ end end class BaseNew < Sequel::Model + def to_hash() + self.values.dup + end + LOCK_TABLES_KEY='__locked_tables' def self.default_row_lock_mode=(mode) raise ArgumentError unless [nil, :share, :update].member?(mode) @default_row_lock_mode = mode @@ -477,11 +487,13 @@ private def self.inherited(klass) super + klass.set_dataset(db[klass.implicit_table_name]) klass.plugin InheritableSchema + klass.plugin :timestamps, :update_on_create=>true klass.class_eval { # Add timestamp columns and set callbacks using Timestamps # plugin. #