Class: Inspector::Constraints::Valid
- Inherits:
-
Object
- Object
- Inspector::Constraints::Valid
- Includes:
- Inspector::Constraint
- Defined in:
- lib/inspector/constraints/valid.rb
Instance Method Summary collapse
-
#initialize(*args) ⇒ Valid
constructor
A new instance of Valid.
- #inspect ⇒ Object
- #to_s ⇒ Object
- #validate_as(value) ⇒ Object
- #validator ⇒ Object
Methods included from Inspector::Constraint
Constructor Details
#initialize(*args) ⇒ Valid
Returns a new instance of Valid.
6 7 8 9 10 11 |
# File 'lib/inspector/constraints/valid.rb', line 6 def initialize(*args) if args.length == 1 @use_custom_type = true @type = args.first end end |
Instance Method Details
#inspect ⇒ Object
26 27 28 |
# File 'lib/inspector/constraints/valid.rb', line 26 def inspect "#<valid%{type}>" % { :type => " #{@type}".rstrip } end |
#to_s ⇒ Object
22 23 24 |
# File 'lib/inspector/constraints/valid.rb', line 22 def to_s "validate" end |
#validate_as(value) ⇒ Object
13 14 15 16 |
# File 'lib/inspector/constraints/valid.rb', line 13 def validate_as(value) return @type if @use_custom_type value.class end |
#validator ⇒ Object
18 19 20 |
# File 'lib/inspector/constraints/valid.rb', line 18 def validator :validity end |