searcher 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -22,8 +22,8 @@ To define labels for your field, use the `searcher` method inside your model lik
22
22
  has_and_belongs_to_many :tags
23
23
 
24
24
  searcher do
25
- external :tag, :from => :tags, :field => "name"
26
- external :state, :from => :state, :field => "name"
25
+ label :tag, :from => :tags, :field => "name"
26
+ label :state, :from => :state, :field => "name"
27
27
  end
28
28
  end
29
29
 
@@ -13,9 +13,9 @@ module Searcher
13
13
  result = query.split(" ").inject(klass) do |k, piece|
14
14
  if piece.include?(":")
15
15
  name, q = piece.split(":")
16
- external = @config[:externals][name.to_sym]
17
- next unless external
18
- send("by_#{name}", q, external[:field])
16
+ label = @config[:labels][name.to_sym]
17
+ next unless label
18
+ send("by_#{name}", q, label[:field])
19
19
  end
20
20
  end
21
21
 
@@ -9,9 +9,9 @@ module Searcher
9
9
  @config
10
10
  end
11
11
 
12
- def external(field, options)
13
- @config[:externals] ||= {}
14
- @config[:externals][field.to_sym] = options
12
+ def label(field, options)
13
+ @config[:labels] ||= {}
14
+ @config[:labels][field.to_sym] = options
15
15
  @config
16
16
  end
17
17
  end
@@ -1,3 +1,3 @@
1
1
  module Searcher
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/searcher.rb CHANGED
@@ -13,7 +13,7 @@ ActiveRecord::Base.extend(Searcher::ClassMethods)
13
13
  ActiveSupport.on_load(:after_initialize) do
14
14
  Searcher.classes.each do |klass|
15
15
  table = Table(klass.table_name)
16
- klass.searcher[:externals].each do |name, config|
16
+ klass.searcher[:labels].each do |name, config|
17
17
  association = klass.reflect_on_association(config[:from])
18
18
  association_table = Table(association.klass.table_name)
19
19
  if [:has_and_belongs_to_many, :belongs_to].include?(association.macro)
data/searcher.sqlite3 CHANGED
Binary file
@@ -3,8 +3,8 @@ class Ticket < ActiveRecord::Base
3
3
  belongs_to :state
4
4
 
5
5
  searcher do
6
- external :tag, :from => :tags, :field => "name"
7
- external :state, :from => :state, :field => "name"
6
+ label :tag, :from => :tags, :field => "name"
7
+ label :state, :from => :state, :field => "name"
8
8
  end
9
9
  end
10
10
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: searcher
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors: []
13
13
 
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-04 00:00:00 +11:00
18
+ date: 2010-10-05 00:00:00 +11:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency