Class: DistritoTracking::Schema
- Inherits:
-
Object
- Object
- DistritoTracking::Schema
- Defined in:
- lib/distrito_tracking/schema.rb
Constant Summary collapse
- DEFAULT_SCHEMA =
{ appName: String, event: { name: String, type: String }, feature: { name: String }, time: Time }.freeze
Instance Attribute Summary collapse
-
#errors ⇒ Object
Returns the value of attribute errors.
Instance Method Summary collapse
-
#initialize ⇒ Schema
constructor
A new instance of Schema.
- #inspect ⇒ Object
- #validate(data:) ⇒ Object
Constructor Details
#initialize ⇒ Schema
Returns a new instance of Schema.
21 22 23 |
# File 'lib/distrito_tracking/schema.rb', line 21 def initialize @errors = {} end |
Instance Attribute Details
#errors ⇒ Object
Returns the value of attribute errors.
19 20 21 |
# File 'lib/distrito_tracking/schema.rb', line 19 def errors @errors end |
Instance Method Details
#inspect ⇒ Object
33 34 35 |
# File 'lib/distrito_tracking/schema.rb', line 33 def inspect "#<DistritoTracking::Schema>" end |
#validate(data:) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/distrito_tracking/schema.rb', line 25 def validate(data:) errors[:data] = "Data provided is invalid" if data.empty? || !data.is_a?(Hash) iterate(data, DEFAULT_SCHEMA) @errors.empty? end |