Module: Mobility::Plugins::AttributeMethods

Defined in:
lib/mobility/plugins/attribute_methods.rb

Overview

Note:

Adding translated attributes to attributes can have unexpected consequences, since these attributes do not have corresponding columns in the model table. Using this plugin may lead to conflicts with other gems.

Adds translated attribute names and values to the hash returned by #attributes. Also adds a method #translated_attributes with names and values of translated attributes only.

Class Method Summary collapse

Class Method Details

.apply(attributes, option) ⇒ Object

Applies attribute_methods plugin for a given option value.

Parameters:

  • attributes (Attributes)
  • option (Boolean)

    Value of option

Raises:

  • (ArgumentError)

    if model class does not support dirty tracking


20
21
22
23
24
# File 'lib/mobility/plugins/attribute_methods.rb', line 20

def apply(attributes, option)
  if option
    include_attribute_methods_module(attributes.model_class, *attributes.names)
  end
end