Module: Chronicle::Models

Extended by:
Builder
Includes:
Generation
Defined in:
lib/chronicle/models.rb,
lib/chronicle/models/base.rb,
lib/chronicle/models/builder.rb,
lib/chronicle/models/generation.rb,
lib/chronicle/models/model_factory.rb

Defined Under Namespace

Modules: Builder, Generation Classes: AttributeError, Base, Error, ModelFactory

Class Method Summary collapse

Methods included from Builder

build

Methods included from Generation

included, reset, suppress_model_generation

Class Method Details

.schema_type(types) ⇒ Object



86
87
88
89
90
91
92
93
94
# File 'lib/chronicle/models/base.rb', line 86

def self.schema_type(types)
  Chronicle::Schema::Types::Instance(Chronicle::Models::Base).constructor do |input|
    unless input.type_id && [types].flatten.include?(input.type_id)
      raise Dry::Types::ConstraintError.new(:type?, input)
    end

    input
  end
end