Class: DataModel::Model
- Inherits:
-
Object
- Object
- DataModel::Model
- Extended by:
- T::Sig
- Defined in:
- lib/data_model/model.rb
Instance Attribute Summary collapse
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
Instance Method Summary collapse
- #coerce(data) ⇒ Object
-
#initialize(schema, type) ⇒ Model
constructor
A new instance of Model.
- #validate(data) ⇒ Object
Constructor Details
#initialize(schema, type) ⇒ Model
Returns a new instance of Model.
8 9 10 11 |
# File 'lib/data_model/model.rb', line 8 def initialize(schema, type) @schema = schema @type = type end |
Instance Attribute Details
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
14 15 16 |
# File 'lib/data_model/model.rb', line 14 def schema @schema end |
Instance Method Details
#coerce(data) ⇒ Object
26 27 28 29 |
# File 'lib/data_model/model.rb', line 26 def coerce(data) result = @type.read(data, coerce: true) return result end |
#validate(data) ⇒ Object
19 20 21 22 |
# File 'lib/data_model/model.rb', line 19 def validate(data) _, err = @type.read(data) return err end |