Module: ActiveUUID::Patches::Column

Extended by:
ActiveSupport::Concern
Defined in:
lib/activeuuid/patches.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.prepended(_klass) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/activeuuid/patches.rb', line 59

def self.prepended(_klass)
  def type_cast(value)
    return UUIDTools::UUID.serialize(value) if type == :uuid
    super
  end

  def type_cast_code(var_name)
    return "UUIDTools::UUID.serialize(#{var_name})" if type == :uuid
    super
  end

  def simplified_type(field_type)
    return :uuid if field_type == "binary(16)" || field_type == "binary(16,0)"
    super
  end
end

Instance Method Details

#simplified_type(field_type) ⇒ Object



70
71
72
73
# File 'lib/activeuuid/patches.rb', line 70

def simplified_type(field_type)
  return :uuid if field_type == "binary(16)" || field_type == "binary(16,0)"
  super
end

#type_cast(value) ⇒ Object



60
61
62
63
# File 'lib/activeuuid/patches.rb', line 60

def type_cast(value)
  return UUIDTools::UUID.serialize(value) if type == :uuid
  super
end

#type_cast_code(var_name) ⇒ Object



65
66
67
68
# File 'lib/activeuuid/patches.rb', line 65

def type_cast_code(var_name)
  return "UUIDTools::UUID.serialize(#{var_name})" if type == :uuid
  super
end