Class: ExportToGcloud::Exporter::Context
- Inherits:
-
Object
- Object
- ExportToGcloud::Exporter::Context
- Defined in:
- lib/export_to_gcloud/exporter/context.rb
Constant Summary collapse
- OPTIONS =
%i[dump_path storage_prefix bucket dataset].freeze
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #copy ⇒ Object
-
#initialize(client, **opts) ⇒ Context
constructor
A new instance of Context.
- #set(**opts) ⇒ Object
- #set_bucket(bucket) ⇒ Object
- #set_dataset(dataset) ⇒ Object
- #set_dump_path(path) ⇒ Object
- #set_storage_prefix(prefix) ⇒ Object
Constructor Details
#initialize(client, **opts) ⇒ Context
Returns a new instance of Context.
8 9 10 11 |
# File 'lib/export_to_gcloud/exporter/context.rb', line 8 def initialize client, **opts @client = client set opts end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
3 4 5 |
# File 'lib/export_to_gcloud/exporter/context.rb', line 3 def client @client end |
Instance Method Details
#copy ⇒ Object
39 40 41 |
# File 'lib/export_to_gcloud/exporter/context.rb', line 39 def copy self.class.new client, OPTIONS.inject({}){|h, k| h[k] = send k; h} end |
#set(**opts) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/export_to_gcloud/exporter/context.rb', line 13 def set **opts OPTIONS.each do |key| value = opts[key] send "set_#{key}", value if value end self end |
#set_bucket(bucket) ⇒ Object
29 30 31 32 |
# File 'lib/export_to_gcloud/exporter/context.rb', line 29 def set_bucket bucket bucket = get_bucket bucket if String === bucket @bucket = bucket end |
#set_dataset(dataset) ⇒ Object
34 35 36 37 |
# File 'lib/export_to_gcloud/exporter/context.rb', line 34 def set_dataset dataset dataset = get_dataset dataset if String === dataset @dataset = dataset end |
#set_dump_path(path) ⇒ Object
21 22 23 |
# File 'lib/export_to_gcloud/exporter/context.rb', line 21 def set_dump_path path @dump_path = Pathname.new path end |
#set_storage_prefix(prefix) ⇒ Object
25 26 27 |
# File 'lib/export_to_gcloud/exporter/context.rb', line 25 def set_storage_prefix prefix @storage_prefix = prefix end |