Class: Mobility::Backends::ActiveRecord::KeyValue::Visitor

Plugins::Arel::Visitor show all
Defined in:


Internal class used to visit all nodes in a predicate clause and return a hash of key/value pairs corresponding to attributes (keys) and the respective join type (values) required for each attribute.


class Post < ApplicationRecord
  extend Mobility
  translates :title, :content, backend: :key_value

backend_class = Post.mobility_backend_class(:title)
visitor =, :en)

title   = backend_class.build_node("title", :en)   # arel node for title
content = backend_class.build_node("content", :en) # arel node for content

#=> { title: Arel::Nodes::InnerJoin, content: Arel::Nodes::OuterJoin }

The title predicate has a non-nil value, so we can use an INNER JOIN, whereas we are searching for nil content, which requires an OUTER JOIN.

Constant Summary

Constants inherited from Plugins::Arel::Visitor

Plugins::Arel::Visitor::INNER_JOIN, Plugins::Arel::Visitor::OUTER_JOIN

Instance Attribute Summary

Attributes inherited from Plugins::Arel::Visitor

#backend_class, #locale

Method Summary

Methods inherited from Plugins::Arel::Visitor


Constructor Details

This class inherits a constructor from Mobility::Plugins::Arel::Visitor