lib/pr/form.rb in pr-0.0.1 vs lib/pr/form.rb in pr-0.0.2
- old
+ new
@@ -1,14 +1,29 @@
module PR
module Form
def self.included other
- other.send :extend, DSL
+ other.send :extend, DSL
+ other.send :include, Macros
end
module DSL
- def field name, options = {}
- DefineAndRegister[ self, name, options ]
+ def field name, type, options = {}
+ PR::DefineAndRegister[ self, name, type, options ]
+ end
+ def from_hash hash
+ form = new
+ PR::BuildFromHash[ form, hash ]
+ form
+ end
+ def from_model model
+ PR::BuildFromModel[ self, model ]
+ end
+ end
+
+ module Macros
+ def build_model model
+ BuildModel[ self, model ]
end
end
end
end