Module: Methodic

Defined in:
lib/methodic.rb

Overview

Note:

this module include a class, but please use the module method Methodic::get_options to Build a Methodic::Options instance

module Methodic

Examples:

Complete usage

require 'rubygems'
require 'methodic'
[...]
# in a method
def amethod ( _options = {})
  myOptions = Methodic::get_options(_options,true) do |m|
    m.specify_known_options [:country,:name,:surname,:age]
    m.specify_default_value :country => 'France'
    aCond = Proc::new {|option| case options when 'Doe' then true else false end }
    m.specify_condition_for :name => aCond
    m.specify_classes_of :name => String, :surname => String, :age => Fixnum, :country => String
    m.specify_presence_of :name
    m.specify_presence_of :surname
    m.specify_formats_of :name => /\w+/, :surname => /\w+/, :country => /\w+/
    m.merge
  end
  # processing method
end
[...]

See Also:

Author:

Version:

  • 0.2

Defined Under Namespace

Classes: Options

Class Method Summary collapse

Class Method Details

.get_options(_options = {}, _validate_known_options = false) ⇒ Options

Note:

_options key must be symbols

Module method factory to build [Options] instance

Examples:

usage

myOptions = Methodic::get_options({:foo => 'bar'})
p myOptions.class
=> Options

Parameters:

  • _options (Hash) (defaults to: {})

    the options [Hash] from the method, you want to prototype

Returns:



379
380
381
# File 'lib/methodic.rb', line 379

def Methodic::get_options(_options = {},_validate_known_options=false)
  return Methodic::Options::new(_options,_validate_known_options)
end