Class: StructuredStore::VersionedSchema
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- StructuredStore::VersionedSchema
- Defined in:
- app/models/structured_store/versioned_schema.rb
Overview
This model stores individual versions of each structured store schema
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.latest(name) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'app/models/structured_store/versioned_schema.rb', line 18 def self.latest(name) schemas = where(name: name) # Return nil if no schemas with this name exist return nil if schemas.empty? # Sort by version using gem_version and return the last one (highest version) schemas.max_by(&:gem_version) end |
.table_name_prefix ⇒ Object
14 15 16 |
# File 'app/models/structured_store/versioned_schema.rb', line 14 def self.table_name_prefix 'structured_store_' end |
Instance Method Details
#gem_version ⇒ Object
37 38 39 |
# File 'app/models/structured_store/versioned_schema.rb', line 37 def gem_version Gem::Version.new(version) end |
#json_schema=(json) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'app/models/structured_store/versioned_schema.rb', line 28 def json_schema=(json) case json when String super(JSON.parse(json)) else super end end |