Class: Pre::Validator
Instance Attribute Summary collapse
Instance Method Summary
collapse
#cache_key, expiry, #valid_domain?
#valid_format?
Constructor Details
#initialize(options = {}) ⇒ Validator
Returns a new instance of Validator.
13
14
15
|
# File 'lib/pre/validator.rb', line 13
def initialize options = {}
@options = defaults options
end
|
Instance Attribute Details
#raw_address ⇒ Object
Returns the value of attribute raw_address.
11
12
13
|
# File 'lib/pre/validator.rb', line 11
def raw_address
@raw_address
end
|
Instance Method Details
#address=(new_address) ⇒ Object
24
25
26
27
|
# File 'lib/pre/validator.rb', line 24
def address= new_address
@parsed = nil
@raw_address = new_address
end
|
#cache_fetch(key, &block) ⇒ Object
37
38
39
|
# File 'lib/pre/validator.rb', line 37
def cache_fetch key, &block
@options[:cache_store].fetch key, &block
end
|
#cache_read(key) ⇒ Object
29
30
31
|
# File 'lib/pre/validator.rb', line 29
def cache_read key
@options[:cache_store].read key
end
|
#cache_write(key, value) ⇒ Object
33
34
35
|
# File 'lib/pre/validator.rb', line 33
def cache_write key, value
@options[:cache_store].write key, value
end
|
#valid?(address, options = {}) ⇒ Boolean
17
18
19
20
21
22
|
# File 'lib/pre/validator.rb', line 17
def valid? address, options = {}
self.address= address
validators(options[:validators]).all? do |strategy|
validate strategy
end
end
|