Class: StubRequests::Concerns::Property::Validator
- Includes:
- ArgumentValidation
- Defined in:
- lib/stub_requests/concerns/property/validator.rb
Overview
Class Validator provides validation for adding properties
Instance Attribute Summary collapse
- #default ⇒ Object readonly
- #name ⇒ Object readonly
- #properties ⇒ Object readonly
- #type ⇒ Object readonly
Class Method Summary collapse
-
.call(name, type, default, properties) ⇒ void
Validates that the property can be added to the class.
Instance Method Summary collapse
-
#initialize(name, type, default = nil, properties = {}) ⇒ Validator
constructor
Initializes a new Validator.
-
#run_validations ⇒ void
Performs all validations.
Methods included from ArgumentValidation
Constructor Details
#initialize(name, type, default = nil, properties = {}) ⇒ Validator
Initializes a new StubRequests::Concerns::Property::Validator
70 71 72 73 74 75 |
# File 'lib/stub_requests/concerns/property/validator.rb', line 70 def initialize(name, type, default = nil, properties = {}) @type = Array(type).flatten @default = default @name = name @properties = properties || {} end |
Instance Attribute Details
#default ⇒ Object (readonly)
57 58 59 |
# File 'lib/stub_requests/concerns/property/validator.rb', line 57 def default @default end |
#name ⇒ Object (readonly)
49 50 51 |
# File 'lib/stub_requests/concerns/property/validator.rb', line 49 def name @name end |
#properties ⇒ Object (readonly)
61 62 63 |
# File 'lib/stub_requests/concerns/property/validator.rb', line 61 def properties @properties end |
#type ⇒ Object (readonly)
53 54 55 |
# File 'lib/stub_requests/concerns/property/validator.rb', line 53 def type @type end |
Class Method Details
.call(name, type, default, properties) ⇒ void
This method returns an undefined value.
Validates that the property can be added to the class
42 43 44 |
# File 'lib/stub_requests/concerns/property/validator.rb', line 42 def self.call(name, type, default, properties) new(name, type, default, properties).run_validations end |
Instance Method Details
#run_validations ⇒ void
This method returns an undefined value.
Performs all validations
87 88 89 90 91 |
# File 'lib/stub_requests/concerns/property/validator.rb', line 87 def run_validations validate_undefined validate_name validate_default end |