lib/trestle/form/builder.rb in trestle-0.9.6 vs lib/trestle/form/builder.rb in trestle-0.9.7
- old
+ new
@@ -7,27 +7,27 @@
# Builder instance will not respond_to?(:display) allowing the method to
# be dispatched to the template helpers instead.
undef_method :display
cattr_accessor :fields
- self.fields = {}
+ self.fields = Lazy::Hash.new
def errors(name)
if object.respond_to?(:errors) && object.errors.respond_to?(:[])
object.errors[name].to_a
else
[]
end
end
- def self.register(name, klass)
+ def self.register(name, field)
rename_existing_helper_method(name)
- self.fields[name] = klass
+ self.fields[name] = field
end
protected
def respond_to_missing?(name, include_all=false)
- self.class.fields.has_key?(name) || super
+ self.class.fields.key?(name) || super
end
def method_missing(name, *args, &block)
if field = self.class.fields[name]
field.new(self, @template, *args, &block).render