Module: Mwc::Utils::Option::ClassMethods

Defined in:
lib/mwc/utils/option.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#cast(value, type) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Cast value to specify type

Parameters:

  • value (Object)

    the origin value

  • type (Symbol)

    the destination type

Since:

  • 0.3.0



43
44
45
46
47
48
49
50
51
# File 'lib/mwc/utils/option.rb', line 43

def cast(value, type)
  return if value.nil?

  case type
  when :path then Mwc.root.join(value)
  when :bool then value == true
  else value
  end
end

#option(name, options = {}) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Define new options

Parameters:

  • name (String)

    the option name

Since:

  • 0.3.0



29
30
31
32
33
34
# File 'lib/mwc/utils/option.rb', line 29

def option(name, options = {})
  return create_array_option(name, options) if options[:array] == true

  option_reader(name, options)
  option_writer(name, options)
end