Sha256: 4030e17c278e10364d703d1cad994031251fe1af1ce92455e9685091ff0f8234
Contents?: true
Size: 1.81 KB
Versions: 2
Compression:
Stored size: 1.81 KB
Contents
#************************************************************************************* # TOCOMMENT #************************************************************************************* module Caisson::Helpers::Form::Field class Base #************************************************************************************* # CONSTRUCTOR #************************************************************************************* def initialize(core) @core = core end private #************************************************************************************* # PRIVATE INSTANCE METHODS #************************************************************************************* def parse_text_options(options) options[:class] = ['text-field', options.delete(:class), options.delete(:field_size)].compact.join(' ') if options[:validates] options["data-validations"] = options.delete(:validates) case when options["data-validations"].include?('max-') then options[:maxlength] = options["data-validations"].match(/max-[0-9]+/).to_s.split('-').last.to_i when options["data-validations"].include?('within-') then options[:maxlength] = options["data-validations"].match(/within-([0-9]+)-([0-9]+)/).to_s.split('-').last.to_i when options["data-validations"].include?('creditcard-') then options[:maxlength] = 19 end end return options end def method_missing(*args, &block) if [:check_box_tag, :content_tag, :hidden_field_tag, :options_for_select, :password_field_tag, :select_tag, :text_area_tag, :text_field_tag].include?(args.first) return @core.send(*args, &block) else raise NoMethodError.new("undefined local variable or method '#{args.first}' for #{self.class}") end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
caisson-0.0.3 | lib/caisson/helpers/form/field/base.rb |
caisson-0.0.2 | lib/caisson/helpers/form/field/base.rb |