Sha256: f3ad5ba4addc12bff91f4505d5e41bde9c0b2d62c19b12f4dab988f059dea233

Contents?: true

Size: 969 Bytes

Versions: 7

Compression:

Stored size: 969 Bytes

Contents

module Ransack
  module Naming

    def self.included(base)
      base.extend ClassMethods
    end

    def persisted?
      false
    end

    def to_key
      nil
    end

    def to_param
      nil
    end

    def to_model
      self
    end
  end

  class Name < String
    attr_reader :singular, :plural, :element, :collection, :partial_path,
                :human, :param_key, :route_key, :i18n_key
    alias_method :cache_key, :collection

    def initialize
      super("Search")
      @singular = "search".freeze
      @plural = "searches".freeze
      @element = "search".freeze
      @human = "Search".freeze
      @collection = "ransack/searches".freeze
      @partial_path = "#{@collection}/#{@element}".freeze
      @param_key = "q".freeze
      @route_key = "searches".freeze
      @i18n_key = :ransack
    end
  end

  module ClassMethods
    def model_name
      @_model_name ||= Name.new
    end

    def i18n_scope
      :ransack
    end
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ransack-1.4.1 lib/ransack/naming.rb
ransack-1.4.0 lib/ransack/naming.rb
ransack-1.3.0 lib/ransack/naming.rb
ransack-1.2.3 lib/ransack/naming.rb
ransack-1.2.2 lib/ransack/naming.rb
ransack-1.2.1 lib/ransack/naming.rb
ransack-1.2.0 lib/ransack/naming.rb