Class: Sequel::Postgres::PGArray::Creator

Inherits:
Object
  • Object
show all
Defined in:
lib/sequel/extensions/pg_array.rb

Overview

Callable object that takes the input string and parses it using Parser.

Direct Known Subclasses

JSONCreator

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, converter = nil) ⇒ Creator

Set the type and optional converter callable that will be used.



466
467
468
469
# File 'lib/sequel/extensions/pg_array.rb', line 466

def initialize(type, converter=nil)
  @type = type
  @converter = converter
end

Instance Attribute Details

#converterObject (readonly)

The converter callable that is called on each member of the array to convert it to the correct type.



460
461
462
# File 'lib/sequel/extensions/pg_array.rb', line 460

def converter
  @converter
end

#typeObject (readonly)

The database type to set on the PGArray instances returned.



463
464
465
# File 'lib/sequel/extensions/pg_array.rb', line 463

def type
  @type
end

Instance Method Details

#call(string) ⇒ Object

Parse the string using Parser with the appropriate converter, and return a PGArray with the appropriate database type.



474
475
476
# File 'lib/sequel/extensions/pg_array.rb', line 474

def call(string)
  PGArray.new(Sequel::Postgres.parse_pg_array(string, @converter), @type)
end