Sha256: 95dbb345a7c1d5b7e32616c3789f4c22ccf195419e6cf2943a3f9435dd57a432

Contents?: true

Size: 463 Bytes

Versions: 3

Compression:

Stored size: 463 Bytes

Contents

module Rasti
  module Types
    class Model

      include Castable

      attr_reader :model

      def self.[](model)
        new(model)
      end

      def to_s
        "#{self.class}[#{model}]"
      end
      alias_method :inspect, :to_s

      private

      def initialize(model)
        @model = model
      end

      def valid?(value)
        value.is_a? ::Hash
      end

      def transform(value)
        model.new value
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rasti-types-1.1.1 lib/rasti/types/model.rb
rasti-types-1.1.0 lib/rasti/types/model.rb
rasti-types-1.0.0 lib/rasti/types/model.rb