Class: Hatch::ValidatedAttribute
- Inherits:
-
Object
- Object
- Hatch::ValidatedAttribute
- Defined in:
- lib/hatch.rb
Instance Attribute Summary collapse
-
#attr ⇒ Object
readonly
Returns the value of attribute attr.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attr, value, error, valid) ⇒ ValidatedAttribute
constructor
A new instance of ValidatedAttribute.
- #invalid? ⇒ Boolean
- #valid? ⇒ Boolean
Constructor Details
#initialize(attr, value, error, valid) ⇒ ValidatedAttribute
Returns a new instance of ValidatedAttribute.
108 109 110 |
# File 'lib/hatch.rb', line 108 def initialize(attr, value, error, valid) @attr, @value, @error, @valid = attr, value, error, valid end |
Instance Attribute Details
#attr ⇒ Object (readonly)
Returns the value of attribute attr.
102 103 104 |
# File 'lib/hatch.rb', line 102 def attr @attr end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
102 103 104 |
# File 'lib/hatch.rb', line 102 def error @error end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
102 103 104 |
# File 'lib/hatch.rb', line 102 def value @value end |
Class Method Details
.validate(attr, value, error, &block) ⇒ Object
104 105 106 |
# File 'lib/hatch.rb', line 104 def self.validate(attr, value, error, &block) new(attr, value, error, yield(value)) end |
Instance Method Details
#invalid? ⇒ Boolean
116 117 118 |
# File 'lib/hatch.rb', line 116 def invalid? !@valid end |
#valid? ⇒ Boolean
112 113 114 |
# File 'lib/hatch.rb', line 112 def valid? @valid end |