simple_search 0.0.0 → 0.0.1

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.0
1
+ 0.0.1
@@ -67,76 +67,13 @@ module SimpleSearch
67
67
  end
68
68
 
69
69
  def add_methods_for(model, col, association = nil)
70
- if model.respond_to?(:lookup_for) && model.lookups.has_key?(col.name)
71
- add_lookup_options(col.name, association)
72
- else
73
- case col.type
74
- when :string
75
- add_string_options(col.name, association)
76
- when :decimal, :integer, :bigint, :float
77
- add_numeric_options(col.name, association)
78
- when :date, :datetime
79
- add_date_options(col.name, association)
80
- end
81
- end
82
- end
83
-
84
- def add_lookup_options(column_name, association = nil)
85
- n = column_name
86
- if association
87
- model = association.class_name.constantize
88
- meth = [association.name.to_s, n].join('_').to_sym
89
- else
90
- model = @model
91
- meth = n.to_sym
92
- end
93
- l = model.lookup_for(n)
94
- t = model.table_name
95
- metaclass.instance_eval do
96
- [meth, "#{meth}_not".to_sym].each do |m|
97
- define_method(m) do
98
- options[m]
99
- end
100
-
101
- define_method("#{m}_parameters".to_sym) do
102
- options[m]
103
- end
104
-
105
- define_method("#{m}_concat".to_sym) do
106
- options["#{m}_concat".to_sym] == 'AND' ? 'AND' : 'OR'
107
- end
108
-
109
- define_method("#{m}_choices".to_sym) do |*filters|
110
- filters.flatten!
111
- opts = filters.last.is_a?(Hash) ? filters.pop : {}
112
-
113
- l.sort {|a,b| a[1] <=> b[1]}.map{|a| a[0]}.inject([]) do |ary, key|
114
- if filters.blank? ||
115
- filters.detect{|f|
116
- f.is_a?(Regexp) ? f.match(key.to_s) : key.to_s == f.to_s
117
- }
118
- ary << [l[key], key]
119
- end
120
- ary
121
- end
122
- end
123
- end
124
-
125
- define_method("#{meth}_conditions".to_sym) do
126
- cond = []
127
- [*options[meth]].each do
128
- cond << "FIND_IN_SET(?, #{t}.#{n})"
129
- end
130
- cond
131
- end
132
-
133
- define_method("#{meth}_not_conditions".to_sym) do
134
- cond = []
135
- [*options["#{meth}_not".to_sym]].each do
136
- cond << "NOT FIND_IN_SET(?, #{t}.#{n})"
137
- end
138
- cond
139
- end
70
+ case col.type
71
+ when :string
72
+ add_string_options(col.name, association)
73
+ when :decimal, :integer, :bigint, :float
74
+ add_numeric_options(col.name, association)
75
+ when :date, :datetime
76
+ add_date_options(col.name, association)
140
77
  end
141
78
  end
142
79
 
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{simple_search}
8
- s.version = "0.0.0"
8
+ s.version = "0.0.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ernie Miller"]
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 0
9
- version: 0.0.0
8
+ - 1
9
+ version: 0.0.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ernie Miller