Class: DataModel::Model

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/data_model/model.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#schemaObject (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