Sha256: 31e2fe93b609e2bb0c0546d9c6a90675d9301ce543dd01f80e597692c9584475

Contents?: true

Size: 909 Bytes

Versions: 5

Compression:

Stored size: 909 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

      def inspect
        "Attribute <#{name}>"
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
ransack-1.1.0 lib/ransack/nodes/attribute.rb
ransack-1.0.0 lib/ransack/nodes/attribute.rb
ransack-0.7.2 lib/ransack/nodes/attribute.rb
ransack-0.7.1 lib/ransack/nodes/attribute.rb
ransack_ffcrm-0.7.1 lib/ransack/nodes/attribute.rb