module Methodic
module Methodic
@author Romain GEORGES <romain@ultragreen.net> @see www.ultragreen.net/projects/methodic @version 0.2 @note this module include a class, but please use the module method Methodic::get_options
to Build a Methodic::Options
instance @example 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 [...]
Public Class Methods
get_options(_options = {},_validate_known_options=false)
click to toggle source
Module method factory to build [Options] instance @return [Options] instance @param [Hash] _options the options [Hash] from the method, you want to prototype @example usage
myOptions = Methodic::get_options({:foo => 'bar'}) p myOptions.class => Options
@note _options key must be symbols
# File lib/methodic.rb 379 def Methodic::get_options(_options = {},_validate_known_options=false) 380 return Methodic::Options::new(_options,_validate_known_options) 381 end