Sha256: 5f75e7105abc48d52389981e59dceb172b45698bfed9ed8a50eb832cae3bd6ab

Contents?: true

Size: 850 Bytes

Versions: 10

Compression:

Stored size: 850 Bytes

Contents

module Ransack
  module Nodes
    class Attribute < Node
      include Bindable

      attr_reader :name

      delegate :blank?, :present?, :==, :to => :name
      delegate :engine, :to => :context

      def initialize(context, name = nil)
        super(context)
        self.name = name unless name.blank?
      end

      def name=(name)
        @name = name
        context.bind(self, name) unless name.blank?
      end

      def valid?
        bound? && attr
      end

      def type
        if ransacker
          return ransacker.type
        else
          context.type_for(self)
        end
      end

      def eql?(other)
        self.class == other.class &&
        self.name == other.name
      end
      alias :== :eql?

      def hash
        self.name.hash
      end

      def persisted?
        false
      end

    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
ransack-0.7.0 lib/ransack/nodes/attribute.rb
ransack_ffcrm-0.6.0 lib/ransack/nodes/attribute.rb
ransack-0.6.0 lib/ransack/nodes/attribute.rb
ransack-0.5.8 lib/ransack/nodes/attribute.rb
ransack-0.5.7 lib/ransack/nodes/attribute.rb
ransack-0.5.6 lib/ransack/nodes/attribute.rb
ransack-0.5.5 lib/ransack/nodes/attribute.rb
ransack-0.5.4 lib/ransack/nodes/attribute.rb
ransack-0.5.3 lib/ransack/nodes/attribute.rb
ransack-0.5.2 lib/ransack/nodes/attribute.rb