Sha256: 569cee3266c4ca784a971953d5beed2c11fe131249ab33d4f1d0f5a2ea58a266

Contents?: true

Size: 381 Bytes

Versions: 1

Compression:

Stored size: 381 Bytes

Contents

module DeviceMap
  module Properties
    class Property < Struct.new(:name, :type_name, :source_name)
      TYPE_MAPPING = {
        integer: Types::Integer,
        boolean: Types::Boolean,
        string:  Types::String
      }

      def cast(value)
        return if value.nil?

        type = TYPE_MAPPING.fetch(type_name)
        type.cast(value)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
device_map-0.1.1 lib/device_map/properties/property.rb