Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def self.record *args
- options = args.extract_options!
- options.reverse_merge!(:export_time => Time.now,
- :state => "starting")
- begin
- metadata = ExportMetadata.new
- metadata.set_attributes options
- yield metadata
- metadata.store!
- end
- end
- ExportMetadata.record(:table => @export_obj.table_name,
- :database => @export_obj.source_schema,
- :filepath => filepath) do |metadata|
- if @export_obj.state == "new"
- initial_export metadata
- end
- end
- def initial_export metadata
- @export_obj.ssh_to_source do |ssh|
- metadata.ssh = ssh
- metadata.store!
- end
- end
- -- SSH is set to nil initially in ExportMetadata class
- @ssh = nil
- -- Store method defined in ExportMetadata class
- def store!
- cmd = "cat #{self.to_json} > #{@filepath}.json"
- @ssh.exec!(cmd)
- end
- Calling initial_export throws an exception because @ssh is nil. But it should not be nil, I set in the block:
- initial_export(metadata)
- NoMethodError: undefined method `exec!' for nil:NilClass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement