Module: Kiba::Extend::Registry::Fileable

Included in:
Destinations::Destinationable, Sources::Sourceable
Defined in:
lib/kiba/extend/registry/fileable.rb

Overview

Mix-in module with shared methods for sources and destinations

Since:

  • 4.0.0

Instance Method Summary collapse

Instance Method Details

#default_args(path = nil) ⇒ Object

Parameters:

  • path (String, nil) (defaults to: nil)

Since:

  • 4.0.0



11
12
13
14
15
16
17
18
19
# File 'lib/kiba/extend/registry/fileable.rb', line 11

def default_args(path = nil)
  if requires_path? && path.nil?
    fail Kiba::Extend::PathRequiredError.new(self)
  elsif path.nil?
    labeled_options
  else
    {path_key => path}.merge(labeled_options)
  end
end

#default_file_optionsObject

This method is abstract.

Returns:

  • Hash if default file options are configured in the project

  • Nil of no default file options are configured

Raises:

  • (NotImplementedError)

Since:

  • 4.0.0



24
25
26
27
# File 'lib/kiba/extend/registry/fileable.rb', line 24

def default_file_options
  raise NotImplementedError,
    ":default_file_options must be defined in extending class"
end

#labeled_optionsObject

Returns Hash of file options.

Returns:

  • Hash of file options

Since:

  • 4.0.0



30
31
32
33
34
35
36
# File 'lib/kiba/extend/registry/fileable.rb', line 30

def labeled_options
  if options_key && default_file_options
    {options_key => default_file_options}
  else
    {}
  end
end

#options_keyObject

This method is abstract.

Returns:

  • Symbol used as key for specifying file options, if file options may be passed

  • Nil if no file options may be passed

Raises:

  • (NotImplementedError)

Since:

  • 4.0.0



42
43
44
45
# File 'lib/kiba/extend/registry/fileable.rb', line 42

def options_key
  raise NotImplementedError,
    ":options_key must be defined in extending class"
end

#path_keyObject

This method is abstract.

Returns:

  • Symbol used as key to indicate source path, if path is required

  • Nil if no path is required

Raises:

  • (NotImplementedError)

Since:

  • 4.0.0



51
52
53
54
# File 'lib/kiba/extend/registry/fileable.rb', line 51

def path_key
  raise NotImplementedError,
    ":path_key must be defined in extending class"
end

#requires_path?Boolean

This method is abstract.

Returns Boolean whether path to file must be provided.

Returns:

  • (Boolean)

    Boolean whether path to file must be provided

Raises:

  • (NotImplementedError)

Since:

  • 4.0.0



58
59
60
61
# File 'lib/kiba/extend/registry/fileable.rb', line 58

def requires_path?
  raise NotImplementedError,
    ":requires_path? must be defined in extending class"
end