Class: Bricolage::PSQLLoadOptions
- Inherits:
-
Object
- Object
- Bricolage::PSQLLoadOptions
- Defined in:
- lib/bricolage/psqldatasource.rb
Defined Under Namespace
Classes: Option
Class Method Summary collapse
Instance Method Summary collapse
- #[]=(name, value) ⇒ Object
- #delete(name) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(opts = []) ⇒ PSQLLoadOptions
constructor
A new instance of PSQLLoadOptions.
- #key?(name) ⇒ Boolean
- #merge(pairs) ⇒ Object
- #provide_defaults(src_ds) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(opts = []) ⇒ PSQLLoadOptions
Returns a new instance of PSQLLoadOptions.
448 449 450 |
# File 'lib/bricolage/psqldatasource.rb', line 448 def initialize(opts = []) @opts = opts end |
Class Method Details
.parse(opts) ⇒ Object
403 404 405 406 407 408 409 |
# File 'lib/bricolage/psqldatasource.rb', line 403 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
461 462 463 464 465 |
# File 'lib/bricolage/psqldatasource.rb', line 461 def []=(name, value) n = name.to_s delete n @opts.push Option.new(n, value) end |
#delete(name) ⇒ Object
467 468 469 |
# File 'lib/bricolage/psqldatasource.rb', line 467 def delete(name) @opts.reject! {|opt| opt.name == name } end |
#each(&block) ⇒ Object
457 458 459 |
# File 'lib/bricolage/psqldatasource.rb', line 457 def each(&block) @opts.each(&block) end |
#key?(name) ⇒ Boolean
452 453 454 455 |
# File 'lib/bricolage/psqldatasource.rb', line 452 def key?(name) n = name.to_s @opts.any? {|opt| opt.name == n } end |
#merge(pairs) ⇒ Object
471 472 473 474 475 476 477 478 479 480 |
# File 'lib/bricolage/psqldatasource.rb', line 471 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
490 491 |
# File 'lib/bricolage/psqldatasource.rb', line 490 def provide_defaults(src_ds) end |
#to_s ⇒ Object
482 483 484 485 486 487 488 |
# File 'lib/bricolage/psqldatasource.rb', line 482 def to_s buf = StringIO.new each do |opt| buf.puts opt end buf.string end |