Module: OptionalArgument

Defined in:
lib/optionalargument/store.rb,
lib/optionalargument/errors.rb,
lib/optionalargument/version.rb,
lib/optionalargument/singleton_class.rb,
lib/optionalargument/store/singleton_class.rb

Defined Under Namespace

Classes: KeyConflictError, MalformedOptionsError, Store

Constant Summary collapse

VERSION =
'0.2.1'.freeze

Class Method Summary collapse

Class Method Details

.define(&block) ⇒ void

This method returns an undefined value.

Returns must block given

Yield Returns:

  • (Class)

    subclass of Store

Raises:

  • (ArgumentError)

9
10
11
12
13
14
15
16
17
# File 'lib/optionalargument/singleton_class.rb', line 9

def define(&block)
  raise ArgumentError, 'block was not given' unless block_given?

  Class.new(Store) {
    _init
    class_eval(&block)
    _fix
  }
end

.parse(opts, parsing_options = {}, &block) ⇒ Object

Raises:

  • (ArgumentError)

See Also:


20
21
22
23
24
# File 'lib/optionalargument/singleton_class.rb', line 20

def parse(opts, parsing_options={}, &block)
  raise ArgumentError, 'block was not given' unless block_given?
  
  define(&block).parse opts, parsing_options
end