Sha256: 90f34d8835ebf1512e24ef167e7d998c4d060734daf19ae0203c16a16c4c9254

Contents?: true

Size: 1.01 KB

Versions: 37

Compression:

Stored size: 1.01 KB

Contents

module Ransack
  module Nodes
    module Bindable

      attr_accessor :parent, :attr_name

      def attr
        @attr ||= get_arel_attribute
      end
      alias :arel_attribute :attr

      def ransacker
        klass._ransackers[attr_name]
      end

      def klass
        @klass ||= context.klassify(parent)
      end

      def bound?
        attr_name.present? && parent.present?
      end

      def reset_binding!
        @parent = @attr_name = @attr = @klass = nil
      end

      private

      def get_arel_attribute
        if ransacker
          ransacker.attr_from(self)
        else
          get_attribute
        end
      end

      def get_attribute
        if is_alias_attribute?
          context.table_for(parent)[parent.base_klass.attribute_aliases[attr_name]]
        else
          context.table_for(parent)[attr_name]
        end
      end

      def is_alias_attribute?
        Ransack::SUPPORTS_ATTRIBUTE_ALIAS &&
        parent.base_klass.attribute_aliases.key?(attr_name)
      end
    end
  end
end

Version data entries

37 entries across 36 versions & 3 rubygems

Version Path
ransack-4.3.0 lib/ransack/nodes/bindable.rb
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/ransack-4.2.1/lib/ransack/nodes/bindable.rb
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.1.0/gems/ransack-4.2.1/lib/ransack/nodes/bindable.rb
ransack-4.2.1 lib/ransack/nodes/bindable.rb
ransack-4.2.0 lib/ransack/nodes/bindable.rb
ransack-4.1.1 lib/ransack/nodes/bindable.rb
ransack-4.1.0 lib/ransack/nodes/bindable.rb
ransack-4.0.0 lib/ransack/nodes/bindable.rb
ransack-3.2.1 lib/ransack/nodes/bindable.rb
ransack-3.2.0 lib/ransack/nodes/bindable.rb
ransack-3.1.0 lib/ransack/nodes/bindable.rb
ransack-3.0.1 lib/ransack/nodes/bindable.rb
ransack-3.0.0 lib/ransack/nodes/bindable.rb
ransack-2.6.0 lib/ransack/nodes/bindable.rb
ransack-2.5.0 lib/ransack/nodes/bindable.rb
date_n_time_picker_activeadmin-0.1.2 vendor/bundle/ruby/2.6.0/gems/ransack-2.4.2/lib/ransack/nodes/bindable.rb
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/ransack-2.4.2/lib/ransack/nodes/bindable.rb
ransack-2.4.2 lib/ransack/nodes/bindable.rb
ransack-2.4.1 lib/ransack/nodes/bindable.rb
ransack-2.4.0 lib/ransack/nodes/bindable.rb