Sha256: 461a30544063def759f0513d5ec32b88ea326c4af430e4e18b48c62365ca54e5

Contents?: true

Size: 1.09 KB

Versions: 7

Compression:

Stored size: 1.09 KB

Contents

module Mobility
  module Backends
    module ActiveRecord
      def self.included(backend_class)
        backend_class.include(Backend)
        backend_class.extend(ClassMethods)
      end

      module ClassMethods
        # @param [Symbol] name Attribute name
        # @param [Symbol] locale Locale
        def [](name, locale)
          build_node(name.to_s, locale)
        end

        # @param [String] _attr Attribute name
        # @param [Symbol] _locale Locale
        # @return Arel node for this translated attribute
        def build_node(_attr, _locale)
          raise NotImplementedError
        end

        # @param [ActiveRecord::Relation] relation Relation to scope
        # @param [Object] predicate Arel predicate
        # @param [Symbol] locale Locale
        # @option [Boolean] invert
        # @return [ActiveRecord::Relation] Relation with scope added
        def apply_scope(relation, _predicate, _locale, invert: false)
          relation
        end

        private

        def build_quoted(value)
          ::Arel::Nodes.build_quoted(value)
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mobility-0.7.6 lib/mobility/backends/active_record.rb
mobility-0.7.5 lib/mobility/backends/active_record.rb
mobility-0.7.4 lib/mobility/backends/active_record.rb
mobility-0.7.3 lib/mobility/backends/active_record.rb
mobility-0.7.2 lib/mobility/backends/active_record.rb
mobility-0.7.1 lib/mobility/backends/active_record.rb
mobility-0.7.0 lib/mobility/backends/active_record.rb