Class: ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Array
- Inherits:
- 
      Type::Value
      
        - Object
- ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Array
 
- Includes:
- ActiveModel::Type::Helpers::Mutable
- Defined in:
- activerecord/lib/active_record/connection_adapters/postgresql/oid/array.rb
Overview
:nodoc:
Defined Under Namespace
Classes: Data
Instance Attribute Summary collapse
- 
  
    
      #delimiter  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute delimiter. 
- 
  
    
      #subtype  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute subtype. 
Instance Method Summary collapse
- #==(other) ⇒ Object
- #cast(value) ⇒ Object
- #changed_in_place?(raw_old_value, new_value) ⇒ Boolean
- #deserialize(value) ⇒ Object
- #force_equality?(value) ⇒ Boolean
- 
  
    
      #initialize(subtype, delimiter = ",")  ⇒ Array 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Array. 
- #map(value, &block) ⇒ Object
- #serialize(value) ⇒ Object
- #type_cast_for_schema(value) ⇒ Object
Methods included from ActiveModel::Type::Helpers::Mutable
Constructor Details
#initialize(subtype, delimiter = ",") ⇒ Array
Returns a new instance of Array.
| 15 16 17 18 19 20 21 | # File 'activerecord/lib/active_record/connection_adapters/postgresql/oid/array.rb', line 15 def initialize(subtype, delimiter = ",") @subtype = subtype @delimiter = delimiter @pg_encoder = PG::TextEncoder::Array.new name: "#{type}[]", delimiter: delimiter @pg_decoder = PG::TextDecoder::Array.new name: "#{type}[]", delimiter: delimiter end | 
Instance Attribute Details
#delimiter ⇒ Object (readonly)
Returns the value of attribute delimiter.
| 12 13 14 | # File 'activerecord/lib/active_record/connection_adapters/postgresql/oid/array.rb', line 12 def delimiter @delimiter end | 
#subtype ⇒ Object (readonly)
Returns the value of attribute subtype.
| 12 13 14 | # File 'activerecord/lib/active_record/connection_adapters/postgresql/oid/array.rb', line 12 def subtype @subtype end | 
Instance Method Details
#==(other) ⇒ Object
| 56 57 58 59 60 | # File 'activerecord/lib/active_record/connection_adapters/postgresql/oid/array.rb', line 56 def ==(other) other.is_a?(Array) && subtype == other.subtype && delimiter == other.delimiter end | 
#cast(value) ⇒ Object
| 34 35 36 37 38 39 40 41 42 43 44 45 | # File 'activerecord/lib/active_record/connection_adapters/postgresql/oid/array.rb', line 34 def cast(value) if value.is_a?(::String) value = begin @pg_decoder.decode(value) rescue TypeError # malformed array string is treated as [], will raise in PG 2.0 gem # this keeps a consistent implementation [] end end type_cast_array(value, :cast) end | 
#changed_in_place?(raw_old_value, new_value) ⇒ Boolean
| 71 72 73 | # File 'activerecord/lib/active_record/connection_adapters/postgresql/oid/array.rb', line 71 def changed_in_place?(raw_old_value, new_value) deserialize(raw_old_value) != new_value end | 
#deserialize(value) ⇒ Object
| 23 24 25 26 27 28 29 30 31 32 | # File 'activerecord/lib/active_record/connection_adapters/postgresql/oid/array.rb', line 23 def deserialize(value) case value when ::String type_cast_array(@pg_decoder.decode(value), :deserialize) when Data type_cast_array(value.values, :deserialize) else super end end | 
#force_equality?(value) ⇒ Boolean
| 75 76 77 | # File 'activerecord/lib/active_record/connection_adapters/postgresql/oid/array.rb', line 75 def force_equality?(value) value.is_a?(::Array) end | 
#map(value, &block) ⇒ Object
| 67 68 69 | # File 'activerecord/lib/active_record/connection_adapters/postgresql/oid/array.rb', line 67 def map(value, &block) value.is_a?(::Array) ? value.map(&block) : subtype.map(value, &block) end |