Skip to content
This repository has been archived by the owner on Mar 17, 2023. It is now read-only.

Make it possible to use a proc as archiver factory #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

iconara
Copy link
Contributor

@iconara iconara commented Apr 7, 2016

Being limited to classes is inconvenient when you want to create your archiver with additional arguments.

Before you had to do something like this:

class MyArchiverFactory
  def initialize(some_arg)
    @some_arg = some_arg
  end

  def new(*archiver_args)
    MyArchiver.new(some_arg, *archiver_args)
  end
end

class MyArchiver < Jara::Releaser::Archiver
  def initialize(some_arg, *archiver_args)
    super(*archiver_args)
    @some_arg = some_arg
  end

  # …
end

Jara::Releaser.new(environment, bucket_name, archiver: MyArchiverFactory.new('foo'))

With this feature it can instead be done like this:

class MyArchiver < Jara::Releaser::Archiver
  def initialize(some_arg, *archiver_args)
    super(*archiver_args)
    @some_arg = some_arg
  end

  # …
end

Jara::Releaser.new(environment, bucket_name, archiver: proc { |*args| MyArchiver.new('foo', *args) })

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant