Module: UnitMeasurements::Rails::ActiveRecord::Temperature

Defined in:
lib/unit_measurements/rails/unit_groups/temperature.rb

Overview

The UnitMeasurements::Rails::ActiveRecord::Temperature module provides a convenient way to define temperature-measured attributes in ActiveRecord models.

It acts as a wrapper for the measured method, simplifying the definition of temperature-measured attributes without directly invoking the measured method.

Author:

Since:

  • 1.3.0

Class Method Summary collapse

Class Method Details

.measured_temperature(*measured_attrs, **options) ⇒ void

This method returns an undefined value.

Defines temperature-measured attributes in the ActiveRecord model.

This method serves as a wrapper around the measured method and allows easy definition of temperature-measured attributes by accepting an array of attribute names along with their options.

Examples:

Define single temperature-measured attribute:

class WeatherReport < ActiveRecord::Base
  measured_temperature :average_temperature
end

Define multiple temperature-measured attributes:

class WeatherReport < ActiveRecord::Base
  measured_temperature :day_temperature, :night_temperature
end

Parameters:

  • measured_attrs (Array<String|Symbol>)

    An array of the names of temperature-measured attributes.

  • options (Hash)

    A customizable set of options

Options Hash (**options):

  • :quantity_attribute_name (String|Symbol)

    The name of the quantity attribute.

  • :unit_attribute_name (String|Symbol)

    The name of the unit attribute.

See Also:

Author:

Since:

  • 1.3.0



42
43
44
# File 'lib/unit_measurements/rails/unit_groups/temperature.rb', line 42

def measured_temperature(*measured_attrs, **options)
  measured(UnitMeasurements::Temperature, *measured_attrs, **options)
end