Module: Mincer

Defined in:
lib/mincer/base.rb,
lib/mincer.rb,
lib/mincer/config.rb,
lib/mincer/version.rb,
lib/mincer/processors/helpers.rb,
lib/mincer/action_view/sort_helper.rb,
lib/generators/mincer/query_generator.rb,
lib/mincer/processors/sorting/processor.rb,
lib/mincer/processors/pg_search/processor.rb,
lib/mincer/processors/pg_search/sanitizer.rb,
lib/mincer/processors/pagination/processor.rb,
lib/mincer/processors/cache_digest/processor.rb,
lib/mincer/processors/pg_json_dumper/processor.rb,
lib/mincer/processors/pg_search/search_statement.rb,
lib/mincer/processors/pg_search/search_engines/base.rb,
lib/mincer/processors/pg_search/search_engines/array.rb,
lib/mincer/processors/pg_search/search_engines/trigram.rb,
lib/mincer/processors/pg_search/search_engines/fulltext.rb

Overview

This and all processors are heavily influenced by pg_search(github.com/Casecommons/pg_search)

Defined Under Namespace

Modules: ActionView, Generators, PgSearch, Processors, VERSION Classes: Base, Configuration

Class Method Summary collapse

Class Method Details

.add_processor(processor) ⇒ Object



19
20
21
22
23
24
# File 'lib/mincer.rb', line 19

def self.add_processor(processor)
  processor_scope = ::Mincer::Processors.const_get(ActiveSupport::Inflector.camelize(processor.to_s, true))
  ::Mincer.processors << processor_scope.const_get('Processor')
  ::Mincer::Base.send(:include, processor_scope.const_get('Options')) if processor_scope.const_defined?('Options')
  ::Mincer.config.add(processor, processor_scope.const_get('Configuration'))  if processor_scope.const_defined?('Configuration') if processor_scope.const_defined?('Configuration')
end

.configObject



8
9
10
# File 'lib/mincer/config.rb', line 8

def self.config
  @config ||= ::Mincer::Configuration.new
end

.configure {|config| ... } ⇒ Object

Yields:



4
5
6
# File 'lib/mincer/config.rb', line 4

def self.configure
  yield(config)
end

.connectionObject



15
16
17
# File 'lib/mincer.rb', line 15

def self.connection
  ::ActiveRecord::Base.connection()
end

.pg_extension_installed?(extension) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
29
30
31
32
# File 'lib/mincer.rb', line 26

def self.pg_extension_installed?(extension)
  @installed_extensions ||= {}
  if @installed_extensions[extension.to_sym].nil?
    @installed_extensions[extension.to_sym] = ::Mincer.connection.execute("SELECT DISTINCT p.proname FROM pg_proc p WHERE p.proname = '#{extension}'").count > 0
  end
  @installed_extensions[extension.to_sym]
end

.postgres?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/mincer.rb', line 11

def self.postgres?
  self.connection.adapter_name == 'PostgreSQL' rescue false
end

.processorsObject



7
8
9
# File 'lib/mincer.rb', line 7

def self.processors
  @processors ||= []
end

.versionObject



3
4
5
# File 'lib/mincer/version.rb', line 3

def self.version
  Gem::Version.new '0.2.20'
end