Class: DeviceMap::Properties::Property

Inherits:
Struct
  • Object
show all
Defined in:
lib/device_map/properties/property.rb

Constant Summary collapse

TYPE_MAPPING =
{
  integer: Types::Integer,
  boolean: Types::Boolean,
  string:  Types::String
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



3
4
5
# File 'lib/device_map/properties/property.rb', line 3

def name
  @name
end

#source_nameObject

Returns the value of attribute source_name

Returns:

  • (Object)

    the current value of source_name



3
4
5
# File 'lib/device_map/properties/property.rb', line 3

def source_name
  @source_name
end

#type_nameObject

Returns the value of attribute type_name

Returns:

  • (Object)

    the current value of type_name



3
4
5
# File 'lib/device_map/properties/property.rb', line 3

def type_name
  @type_name
end

Instance Method Details

#cast(value) ⇒ Object



10
11
12
13
14
15
# File 'lib/device_map/properties/property.rb', line 10

def cast(value)
  return if value.nil?

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