Module: NeoGruby::Sequel::Plugins::UuidPk::InstanceMethods

Defined in:
lib/neo_gruby/sequel/plugins/uuid_pk.rb

Instance Method Summary collapse

Instance Method Details

#before_validationObject



43
44
45
46
47
48
49
# File 'lib/neo_gruby/sequel/plugins/uuid_pk.rb', line 43

def before_validation
  field = :id
  meth = :"#{field}="
  if respond_to?(field) && respond_to?(meth) && get_column_value(field).nil?
    set_column_value(meth, UUIDTools::UUID.timestamp_create.raw)
  end
end

#idObject



51
52
53
# File 'lib/neo_gruby/sequel/plugins/uuid_pk.rb', line 51

def id
  UuidPk.parse_id(super)
end