Module: ValidatesAndFormatsPhones
- Defined in:
- lib/validates_and_formats_phones/railtie.rb,
lib/validates_and_formats_phones/version.rb,
lib/validates_and_formats_phones/validates_and_formats_phones.rb
Defined Under Namespace
Modules: ClassMethods, InstanceMethods
Classes: Railtie
Constant Summary
collapse
- VERSION =
'1.0.1'
- DEFAULT_FORMAT =
"(###) ###-####"
Class Method Summary
collapse
Class Method Details
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/validates_and_formats_phones/validates_and_formats_phones.rb', line 8
def self.extract_formats_and_fields(formats_and_fields)
options = {:on => :save, :allow_nil => false}
options.merge!(formats_and_fields.)
formats = []
fields = []
formats_and_fields.each do |option|
option.to_s =~ /#/ ?
formats << option :
fields << option.to_sym
end
formats << DEFAULT_FORMAT if formats.empty?
fields << :phone if fields.empty?
[formats, fields, options]
end
|
.included(base) ⇒ Object
3
4
5
6
|
# File 'lib/validates_and_formats_phones/validates_and_formats_phones.rb', line 3
def self.included(base)
base.send :extend, ClassMethods
base.send :include, InstanceMethods
end
|