Class: Strain::SchemaTools::Defaults
- Inherits:
-
Object
- Object
- Strain::SchemaTools::Defaults
- Defined in:
- lib/strain/schema_tools/defaults.rb
Instance Method Summary collapse
- #data_with_defaults ⇒ Object
- #default_values ⇒ Object
-
#initialize(schema_hash, data_hash) ⇒ Defaults
constructor
A new instance of Defaults.
Constructor Details
#initialize(schema_hash, data_hash) ⇒ Defaults
Returns a new instance of Defaults.
5 6 7 8 |
# File 'lib/strain/schema_tools/defaults.rb', line 5 def initialize(schema_hash, data_hash) @schema = schema_hash @data = data_hash end |
Instance Method Details
#data_with_defaults ⇒ Object
15 16 17 |
# File 'lib/strain/schema_tools/defaults.rb', line 15 def data_with_defaults merge_defaults(@data, default_values) end |
#default_values ⇒ Object
10 11 12 13 |
# File 'lib/strain/schema_tools/defaults.rb', line 10 def default_values raise "Invalid schema." unless @schema["type"] == "object" && @schema.has_key?("properties") property_defaults(@schema["properties"]) end |