doc/manual.rdoc in methodic-1.1 vs doc/manual.rdoc in methodic-1.2
- old
+ new
@@ -33,10 +33,12 @@
# in a method
def amethod ( _options = {})
myOptions = Methodic::get_options(_options) do |m|
m.specify_default_value_of :country => 'France'
m.specify_classes_of :name => String, :surname => String, :age => Fixnum, :country => String
+ aCond = Proc::new {|option| case options when 'Doe' then true else false end }
+ m.specify_condition_for :name => aCond
m.specify_presence_of :name
m.specify_presence_of :surname
m.specify_formats_of :name => /\w+/, :surname => /\w+/, :country => /\w+/
m.merge!
end
@@ -51,21 +53,45 @@
[...]
# in a method
def amethod ( _options = {})
myOptions = Methodic::get_options(_options,true) do |m|
# all others definitions MUST be included in known options list (explained in Spec), so : m.specify_known_options [:country,:name,:surname, :age]
- m.specify_default_value_of :country => 'France'
+ m.specify_default_value_of :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
[...]
+=== Remarque about conditions
+
+* Condition MUST :
+
+- be ruby code
+- be a Proc Object
+- have an argument |option| who provide the option symbol, like :an_option
+- return true or false
+
+* Make your condition like
+
+
+ aCond = Proc::new do |option|
+ case options
+ when .... then ...
+ when .... then ...
+ else ...
+ end
+ end
+
+
+
== Copyright
-<pre>Methodic (c) 2012 Romain GEORGES <romain@ultragreen.net> for Ultragreen Software </pre>
+<pre>Methodic (c) 2012-2013 Romain GEORGES <romain@ultragreen.net> for Ultragreen Software </pre>