Class: Bricolage::PSQLLoadOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/bricolage/psqldatasource.rb

Defined Under Namespace

Classes: Option

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = []) ⇒ PSQLLoadOptions

Returns a new instance of PSQLLoadOptions.



430
431
432
# File 'lib/bricolage/psqldatasource.rb', line 430

def initialize(opts = [])
  @opts = opts
end

Class Method Details

.parse(opts) ⇒ Object



385
386
387
388
389
390
391
# File 'lib/bricolage/psqldatasource.rb', line 385

def parse(opts)
  case opts
  when Hash then filter_values(opts)
  when String then parse_string(opts)   # FIXME: remove
  else raise ParameterError, "unsupported value type for load options: #{opts.class}"
  end
end

Instance Method Details

#[]=(name, value) ⇒ Object



443
444
445
446
447
# File 'lib/bricolage/psqldatasource.rb', line 443

def []=(name, value)
  n = name.to_s
  delete n
  @opts.push Option.new(n, value)
end

#delete(name) ⇒ Object



449
450
451
# File 'lib/bricolage/psqldatasource.rb', line 449

def delete(name)
  @opts.reject! {|opt| opt.name == name }
end

#each(&block) ⇒ Object



439
440
441
# File 'lib/bricolage/psqldatasource.rb', line 439

def each(&block)
  @opts.each(&block)
end

#key?(name) ⇒ Boolean

Returns:

  • (Boolean)


434
435
436
437
# File 'lib/bricolage/psqldatasource.rb', line 434

def key?(name)
  n = name.to_s
  @opts.any? {|opt| opt.name == n }
end

#merge(pairs) ⇒ Object



453
454
455
456
457
458
459
460
461
462
# File 'lib/bricolage/psqldatasource.rb', line 453

def merge(pairs)
  h = {}
  @opts.each do |opt|
    h[opt.name] = opt
  end
  pairs.each do |key, value|
    h[key] = Option.new(key, value)
  end
  self.class.new(h.values)
end

#provide_defaults(src_ds) ⇒ Object



472
473
# File 'lib/bricolage/psqldatasource.rb', line 472

def provide_defaults(src_ds)
end

#to_sObject



464
465
466
467
468
469
470
# File 'lib/bricolage/psqldatasource.rb', line 464

def to_s
  buf = StringIO.new
  each do |opt|
    buf.puts opt
  end
  buf.string
end