Module: Mobility::Plugins::ActiveRecord::Query::BackendMethods

Defined in:
lib/mobility/plugins/active_record/query.rb

Instance Method Summary collapse

Instance Method Details

#read(locale) ⇒ Object

Note:

We use instance_variable_get here to get the AttributeSet rather than the hash of attributes. Getting the full hash of attributes is a performance hit and better to avoid if unnecessary.

TODO: Improve this.



62
63
64
65
66
67
68
69
# File 'lib/mobility/plugins/active_record/query.rb', line 62

def read(locale, **)
  if model.instance_variable_defined?(:@attributes) &&
      (model_attributes = model.instance_variable_get(:@attributes)).key?(alias_ = Query.attribute_alias(attribute, locale))
    model_attributes[alias_].value
  else
    super
  end
end