Sha256: 22711a6244b34ad807fa96ab27efb5fb37fc58c39a1a7237104598859fc2bfd1

Contents?: true

Size: 379 Bytes

Versions: 1

Compression:

Stored size: 379 Bytes

Contents

module DeviceMap
  module Properties
    class Property < Struct.new(:name, :type_name, :attr_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.0 lib/device_map/properties/property.rb