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.
521 522 523 |
# File 'lib/bricolage/psqldatasource.rb', line 521 def initialize(opts = []) @opts = opts end |
Class Method Details
.parse(opts) ⇒ Object
476 477 478 479 480 481 482 |
# File 'lib/bricolage/psqldatasource.rb', line 476 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
534 535 536 537 538 |
# File 'lib/bricolage/psqldatasource.rb', line 534 def []=(name, value) n = name.to_s delete n @opts.push Option.new(n, value) end |
#delete(name) ⇒ Object
540 541 542 |
# File 'lib/bricolage/psqldatasource.rb', line 540 def delete(name) @opts.reject! {|opt| opt.name == name } end |
#each(&block) ⇒ Object
530 531 532 |
# File 'lib/bricolage/psqldatasource.rb', line 530 def each(&block) @opts.each(&block) end |
#key?(name) ⇒ Boolean
525 526 527 528 |
# File 'lib/bricolage/psqldatasource.rb', line 525 def key?(name) n = name.to_s @opts.any? {|opt| opt.name == n } end |
#merge(pairs) ⇒ Object
544 545 546 547 548 549 550 551 552 553 |
# File 'lib/bricolage/psqldatasource.rb', line 544 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
563 564 |
# File 'lib/bricolage/psqldatasource.rb', line 563 def provide_defaults(src_ds) end |
#to_s ⇒ Object
555 556 557 558 559 560 561 |
# File 'lib/bricolage/psqldatasource.rb', line 555 def to_s buf = StringIO.new each do |opt| buf.puts opt end buf.string end |