Permalink
Browse files

Added mfa functionality

  • Loading branch information...
1 parent 13adbb0 commit cbb57821022a554506835cd2bdeb35a426c23e4d @Taure committed Aug 11, 2012
Showing with 34 additions and 3 deletions.
  1. +29 −1 docs/readme.md
  2. +1 −1 include/models.hrl
  3. +4 −1 src/ewoc_generate_data.erl
View
@@ -42,4 +42,32 @@ Uuid will use the uuid application to generate a uuid using uuid:get_v4().
[{key, [{uuid, []}]}]
-This will generate a uuid to the field key.
+This will generate a uuid to the field key.
+
+### mfa ###
+
+Added a mfa functionality now, we can use other modules to generate
+data if we want.
+
+This is our module:
+
+ -module(user).
+
+ -export([start/0, return/1]).
+
+ start() ->
+ <<"awesome">>.
+
+ return(N) ->
+ N + 1.
+
+
+ Erlang R15B01 (erts-5.9.1) [source] [64-bit] [smp:3:3] [async-threads:0] [kernel-poll:false]
+
+ Eshell V5.9.1 (abort with ^G)
+ (ewoc@127.0.0.1)1> ewoc_model_handler:create([{book, 2, [{author, [{mfa, {user, start, []}}]}, {title, [{mfa, {user, return, [4]}}]}]}]).
+ [{book,[[{author,<<"awesome">>},{amount,[]},{title,<<"5">>}],
+ [{author,<<"awesome">>},{amount,[]},{title,<<"5">>}]]}]
+
+
+
View
@@ -3,5 +3,5 @@
-define(BOOK, [{title, binary},
{amount, integer},
- {author, string}]).
+ {author, binary}]).
-define(CARS, [{engine, binary}]).
@@ -37,7 +37,10 @@ do_actions([{Action, Option}|T], Acc) ->
{Start, End} = Option,
lists:seq(Start, End);
uuid ->
- uuid:get_v4()
+ uuid:get_v4();
+ mfa ->
+ {Module, Function, Args} = Option,
+ erlang:apply(Module, Function, Args)
end.
-spec words(list(), list()) -> list().

0 comments on commit cbb5782

Please sign in to comment.