Class: RailsArchiver::Transport::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/rails-archiver/transport/base.rb

Direct Known Subclasses

InMemory, S3

Instance Method Summary collapse

Constructor Details

#initialize(model = nil, logger = nil) ⇒ Base

Returns a new instance of Base.

Parameters:

  • model (ActiveRecord::Base) (defaults to: nil)

    the model we will be working with.

  • logger (Logger) (defaults to: nil)


9
10
11
12
13
# File 'lib/rails-archiver/transport/base.rb', line 9

def initialize(model=nil, logger=nil)
  @model = model
  @options = {}
  @logger = logger || ::Logger.new(STDOUT)
end

Instance Method Details

#configure(options) ⇒ Object

Parameters:

  • options (Hash)

    A set of options to work with.



16
17
18
# File 'lib/rails-archiver/transport/base.rb', line 16

def configure(options)
  @options = options
end

#retrieve_archive(location = nil) ⇒ Hash

To be implemented by subclasses. Retrieve the archive that was previously created. S3 key). Otherwise will be figured out from the existing model in the database.

Parameters:

  • location (String) (defaults to: nil)

    if given, the location of the archive (e.g.

Returns:

  • (Hash)

    the retrieved hash.

Raises:

  • (NotImplementedError)


35
36
37
# File 'lib/rails-archiver/transport/base.rb', line 35

def retrieve_archive(location=nil)
  raise NotImplementedError
end

#store_archive(hash) ⇒ Object

To be implemented by subclasses. Store the archive somewhere to be retrieved later. You should also be storing the location somewhere such as on the model. Use @model to reference it. .to_json on it.

Parameters:

  • hash (Hash)

    the hash to store. Generally you’ll want to use

Raises:

  • (NotImplementedError)


25
26
27
# File 'lib/rails-archiver/transport/base.rb', line 25

def store_archive(hash)
  raise NotImplementedError
end