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, logger = nil) ⇒ Base

Returns a new instance of Base.

Parameters:

  • model (ActiveRecord::Base)

    the model we will be working with.



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

def initialize(model, 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.



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

def configure(options)
  @options = options
end

#retrieve_archiveHash

To be implemented by subclasses. Retrieve the archive that was previously created.

Returns:

  • (Hash)

    the retrieved hash.

Raises:

  • (NotImplementedError)


31
32
33
# File 'lib/rails-archiver/transport/base.rb', line 31

def retrieve_archive
  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)


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

def store_archive(hash)
  raise NotImplementedError
end