Class: Torque::PostgreSQL::Adapter::OID::EnumSet
- Inherits:
-
Enum
- Object
- ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Enum
- Enum
- Torque::PostgreSQL::Adapter::OID::EnumSet
- Defined in:
- lib/torque/postgresql/adapter/oid/enum_set.rb
Instance Attribute Summary
Attributes inherited from Enum
#enum_klass, #klass, #name, #set_klass
Instance Method Summary collapse
- #deserialize(value) ⇒ Object
-
#initialize(name, enum_klass) ⇒ EnumSet
constructor
A new instance of EnumSet.
- #serialize(value) ⇒ Object
- #type ⇒ Object
-
#type_cast_for_schema(value) ⇒ Object
Always use symbol values for schema dumper.
Methods inherited from Enum
#==, #assert_valid_value, create, #hash
Constructor Details
#initialize(name, enum_klass) ⇒ EnumSet
Returns a new instance of EnumSet.
8 9 10 11 12 13 14 |
# File 'lib/torque/postgresql/adapter/oid/enum_set.rb', line 8 def initialize(name, enum_klass) @name = name + '[]' @klass = Attributes::EnumSet.lookup(name, enum_klass) @set_klass = self @enum_klass = enum_klass end |
Instance Method Details
#deserialize(value) ⇒ Object
20 21 22 23 24 |
# File 'lib/torque/postgresql/adapter/oid/enum_set.rb', line 20 def deserialize(value) return unless value.present? value = value[1..-2].split(',') if value.is_a?(String) cast_value(value) end |
#serialize(value) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/torque/postgresql/adapter/oid/enum_set.rb', line 26 def serialize(value) return if value.blank? value = cast_value(value) return if value.blank? "{#{value.map(&:to_s).join(',')}}" end |
#type ⇒ Object
16 17 18 |
# File 'lib/torque/postgresql/adapter/oid/enum_set.rb', line 16 def type :enum end |
#type_cast_for_schema(value) ⇒ Object
Always use symbol values for schema dumper
35 36 37 |
# File 'lib/torque/postgresql/adapter/oid/enum_set.rb', line 35 def type_cast_for_schema(value) cast_value(value).map(&:to_sym).inspect end |