meta_search 0.9.5 → 0.9.6

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ Changes since 0.9.5 (2010-09-28):
2
+ * Fix issue with formatters supplied s strings
3
+
1
4
  Changes since 0.9.4 (2010-09-18):
2
5
  * Rename check_boxes and collection_check_boxes to checks and
3
6
  collection_checks. Alias to the old names if not already taken. This
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.5
1
+ 0.9.6
@@ -220,7 +220,7 @@ module MetaSearch
220
220
  define_method("#{name}=") do |val|
221
221
  search_attributes[name] = meth.cast_param(val)
222
222
  if meth.validate(search_attributes[name])
223
- return_value = meth.eval(@relation, search_attributes[name])
223
+ return_value = meth.evaluate(@relation, search_attributes[name])
224
224
  if return_value.is_a?(ActiveRecord::Relation)
225
225
  @relation = return_value
226
226
  else
@@ -242,7 +242,7 @@ module MetaSearch
242
242
  search_attributes["#{attribute}_#{predicate}"] = cast_attributes(where.cast || column_type(attribute), val)
243
243
  if where.validate(search_attributes["#{attribute}_#{predicate}"])
244
244
  arel_attribute = get_attribute(attribute)
245
- @relation = where.eval(@relation, arel_attribute, search_attributes["#{attribute}_#{predicate}"])
245
+ @relation = where.evaluate(@relation, arel_attribute, search_attributes["#{attribute}_#{predicate}"])
246
246
  end
247
247
  end
248
248
  end
@@ -65,9 +65,9 @@ module MetaSearch
65
65
  # the class of your parameters, for instance.
66
66
  class Method
67
67
  include Utility
68
-
68
+
69
69
  attr_reader :name, :formatter, :validator, :type
70
-
70
+
71
71
  def initialize(name, opts ={})
72
72
  raise ArgumentError, "Name parameter required" if name.blank?
73
73
  @name = name
@@ -86,7 +86,7 @@ module MetaSearch
86
86
  raise ArgumentError, "Invalid validator for #{name}, should be a Proc."
87
87
  end
88
88
  end
89
-
89
+
90
90
  # Cast the parameter to the type specified in the Method's <tt>type</tt>
91
91
  def cast_param(param)
92
92
  if type.is_a?(Array)
@@ -102,25 +102,25 @@ module MetaSearch
102
102
  cast_attributes(type, param)
103
103
  end
104
104
  end
105
-
105
+
106
106
  # Evaluate the method in the context of the supplied relation and parameter
107
- def eval(relation, param)
107
+ def evaluate(relation, param)
108
108
  if splat_param?
109
109
  relation.send(name, *format_param(param))
110
110
  else
111
111
  relation.send(name, format_param(param))
112
112
  end
113
113
  end
114
-
114
+
115
115
  def splat_param?
116
116
  !!@splat_param
117
117
  end
118
-
118
+
119
119
  # Format a parameter for searching using the Method's defined formatter.
120
120
  def format_param(param)
121
121
  formatter.call(param)
122
122
  end
123
-
123
+
124
124
  # Validate the parameter for use in a search using the Method's defined validator.
125
125
  def validate(param)
126
126
  validator.call(param)
@@ -97,7 +97,7 @@ module MetaSearch
97
97
  end
98
98
 
99
99
  # Evaluate the Where for the given relation, attribute, and parameter(s)
100
- def eval(relation, attribute, param)
100
+ def evaluate(relation, attribute, param)
101
101
  if splat_param?
102
102
  relation.where(attribute.send(predicate, *format_param(param)))
103
103
  else
data/meta_search.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{meta_search}
8
- s.version = "0.9.5"
8
+ s.version = "0.9.6"
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"]
12
- s.date = %q{2010-09-28}
12
+ s.date = %q{2010-09-29}
13
13
  s.description = %q{
14
14
  Allows simple search forms to be created against an AR3 model
15
15
  and its associations, has useful view helpers for sort links
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 9
8
- - 5
9
- version: 0.9.5
8
+ - 6
9
+ version: 0.9.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ernie Miller
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-09-28 00:00:00 -04:00
17
+ date: 2010-09-29 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency