Class: ValidatesIdentity::Identity
- Inherits:
-
Object
- Object
- ValidatesIdentity::Identity
- Defined in:
- lib/validates_identity/identity.rb
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#record ⇒ Object
readonly
Returns the value of attribute record.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #formatted ⇒ Object
-
#initialize(record, attribute, value, options) ⇒ Identity
constructor
A new instance of Identity.
- #valid? ⇒ Boolean
Constructor Details
#initialize(record, attribute, value, options) ⇒ Identity
Returns a new instance of Identity.
7 8 9 10 11 12 |
# File 'lib/validates_identity/identity.rb', line 7 def initialize(record, attribute, value, ) @record = record @attribute = attribute @value = value @options = end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
5 6 7 |
# File 'lib/validates_identity/identity.rb', line 5 def attribute @attribute end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/validates_identity/identity.rb', line 5 def @options end |
#record ⇒ Object (readonly)
Returns the value of attribute record.
5 6 7 |
# File 'lib/validates_identity/identity.rb', line 5 def record @record end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
5 6 7 |
# File 'lib/validates_identity/identity.rb', line 5 def value @value end |
Instance Method Details
#formatted ⇒ Object
26 27 28 29 30 |
# File 'lib/validates_identity/identity.rb', line 26 def formatted return if @validator.nil? @validator.formatted end |
#valid? ⇒ Boolean
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/validates_identity/identity.rb', line 14 def valid? return true if value.blank? return false if [:identity_type].blank? validator_class = ValidatesIdentity.get_validator(identity_type, type: [:only]) return false if validator_class.nil? @validator = validator_class.new(value) @validator.valid? end |