class Trestle::Form::Builder
Public Class Methods
register(name, klass)
click to toggle source
# File lib/trestle/form/builder.rb, line 22 def self.register(name, klass) rename_existing_helper_method(name) self.fields[name] = klass end
Protected Class Methods
rename_existing_helper_method(name)
click to toggle source
# File lib/trestle/form/builder.rb, line 40 def self.rename_existing_helper_method(name) # Check if a method exists with the given name return unless method_defined?(name) # Prevent a method from being aliased twice return if method_defined?(:"raw_#{name}") alias_method :"raw_#{name}", name undef_method name end
Public Instance Methods
errors(name)
click to toggle source
# File lib/trestle/form/builder.rb, line 14 def errors(name) if object.respond_to?(:errors) && object.errors.respond_to?(:[]) object.errors[name].to_a else [] end end
Protected Instance Methods
method_missing(name, *args, &block)
click to toggle source
Calls superclass method
# File lib/trestle/form/builder.rb, line 32 def method_missing(name, *args, &block) if field = self.class.fields[name] field.new(self, @template, *args, &block).render else super end end
respond_to_missing?(name, include_all=false)
click to toggle source
Calls superclass method
# File lib/trestle/form/builder.rb, line 28 def respond_to_missing?(name, include_all=false) self.class.fields.has_key?(name) || super end