lib/hungryform/elements/base_group.rb in hungryform-0.0.1 vs lib/hungryform/elements/base_group.rb in hungryform-0.0.2
- old
+ new
@@ -24,22 +24,17 @@
def initialize(name, parent, resolver, options = {}, &block)
raise HungryFormException, 'No group structure block given' unless block_given?
super
+
+ @elements = []
+ @errors = {}
- self.name = parent.nil?? name : "#{parent.name}_#{name}"
- self.elements = []
- self.errors = {}
-
instance_eval(&block)
end
- def group(name, options = {}, &block)
- elements << HungryForm::Group.new(name, self, @resolver, options, &block)
- end
-
# Validates an entire group. If a group consists of nested groups
# they will be validated recursively
def valid?
errors.clear
is_valid = true
@@ -67,10 +62,10 @@
#Find a matching class
klass = HungryForm.constants.find {|c| Class === HungryForm.const_get(c) && c.to_s.underscore.to_sym == name}
return super if klass.nil?
# Create a new element based on a symbol provided and push it into the group elements array
- element = HungryForm::const_get(klass).send(:new, *([args[0], self, @resolver, args[1..-1]].flatten), &block)
+ element = HungryForm::const_get(klass).send(:new, args[0], self, @resolver, *(args[1..-1]), &block)
elements << element
#Resolver keeps a hash of all elements of the form
@resolver.elements[element.name] = element
\ No newline at end of file