Module: Formeze
- Defined in:
- lib/formeze.rb
Defined Under Namespace
Modules: ArrayAttrAccessor, ClassMethods, InstanceMethods
Classes: Field, FieldSet, Form, KeyError, Label, Validation, ValidationError, ValueError
Class Method Summary
collapse
Class Method Details
.scrub(input, method_names) ⇒ Object
358
359
360
361
362
|
# File 'lib/formeze.rb', line 358
def self.scrub(input, method_names)
Array(method_names).inject(input) do |tmp, method_name|
scrub_methods.fetch(method_name).call(tmp)
end
end
|
.scrub_methods ⇒ Object
348
349
350
351
352
353
354
355
356
|
# File 'lib/formeze.rb', line 348
def self.scrub_methods
@scrub_methods ||= {
:strip => :strip.to_proc,
:upcase => :upcase.to_proc,
:downcase => :downcase.to_proc,
:squeeze => proc { |string| string.squeeze(' ') },
:squeeze_lines => proc { |string| string.gsub(/(\r?\n)(\r?\n)(\r?\n)+/, '\\1\\2') }
}
end
|
.setup(form) ⇒ Object
368
369
370
371
372
|
# File 'lib/formeze.rb', line 368
def self.setup(form)
form.send :include, InstanceMethods
form.extend ClassMethods
end
|
.translate(key, options) ⇒ Object
364
365
366
|
# File 'lib/formeze.rb', line 364
def self.translate(key, options)
defined?(I18n) ? I18n.translate(key, options) : options.fetch(:default)
end
|