Class: Creed::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/creed/command.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.perform(*context, &block) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/creed/command.rb', line 9

def self.perform(*context, &block)
  # Make sure that any given options have their keys symbolized, otherwise they will be ignored,
  # as Dry::Initializer requires keyword arguments or symbolized keys.
  options = context.extract_options!

  unless options.empty?
    options.symbolize_keys!

    # Raise on unknown options.
    unknown_keys = options.keys - dry_initializer.options.map(&:source)
    raise ArgumentError, "unknown keys: `#{unknown_keys.join '`, `'}`" if unknown_keys.any?
  end

  (options.empty? ? new(*context) : new(*context, **options)).perform(&block)
end

Instance Method Details

#performObject

Raises:

  • (NotImplementedError)


25
26
27
# File 'lib/creed/command.rb', line 25

def perform
  raise NotImplementedError
end