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.



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

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

Class Method Details

.parse(opts) ⇒ Object



391
392
393
394
395
396
397
# File 'lib/bricolage/psqldatasource.rb', line 391

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



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

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

#delete(name) ⇒ Object



455
456
457
# File 'lib/bricolage/psqldatasource.rb', line 455

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

#each(&block) ⇒ Object



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

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

#key?(name) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#merge(pairs) ⇒ Object



459
460
461
462
463
464
465
466
467
468
# File 'lib/bricolage/psqldatasource.rb', line 459

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



478
479
# File 'lib/bricolage/psqldatasource.rb', line 478

def provide_defaults(src_ds)
end

#to_sObject



470
471
472
473
474
475
476
# File 'lib/bricolage/psqldatasource.rb', line 470

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