Class: ExportToGcloud::Exporter::Context

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#clientObject (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

#copyObject



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