Sha256: cd4496d12dafe68e2a79b28807972b8a79dd3bd5e34a0e0129f6179d94d88ef2

Contents?: true

Size: 409 Bytes

Versions: 3

Compression:

Stored size: 409 Bytes

Contents

require 'coverage_helper'
require 'minitest/autorun'
require 'minitest/colorin'
require 'pry-nav'
require 'rasti-model'

T = Rasti::Types

Point = Rasti::Model[:x, :y]

Point3D = Point[:z]

class Position < Rasti::Model
  attribute :type,  T::Enum['2D', '3D'], default: '2D'
  attribute :point, :cast_point

  private

  def cast_point(value)
    type == '2D' ? Point.new(value) : Point3D.new(value)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rasti-model-2.0.0 spec/minitest_helper.rb
rasti-model-1.0.1 spec/minitest_helper.rb
rasti-model-1.0.0 spec/minitest_helper.rb