From 181f03bf6fba72e484965aac04fbc53e193a8a27 Mon Sep 17 00:00:00 2001 From: Igal Koshevoy Date: Sun, 16 Oct 2011 00:08:31 -0700 Subject: [PATCH] Fix "acts_as_solr" to work with Ruby 1.9.2. --- .../plugins/acts_as_solr/lib/acts_methods.rb | 4 +-- .../acts_as_solr/lib/common_methods.rb | 28 +++++++++---------- .../acts_as_solr/lib/instance_methods.rb | 6 ++-- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/vendor/plugins/acts_as_solr/lib/acts_methods.rb b/vendor/plugins/acts_as_solr/lib/acts_methods.rb index fba00cf..71163a5 100644 --- a/vendor/plugins/acts_as_solr/lib/acts_methods.rb +++ b/vendor/plugins/acts_as_solr/lib/acts_methods.rb @@ -149,7 +149,7 @@ def get_field_value(field) value = self[field] || self.instance_variable_get("@#{field.to_s}".to_sym) || self.send(field.to_sym) case type # format dates properly; return nil for nil dates - when :date: value ? value.utc.strftime("%Y-%m-%dT%H:%M:%SZ") : nil + when :date then value ? value.utc.strftime("%Y-%m-%dT%H:%M:%SZ") : nil else value end rescue @@ -169,4 +169,4 @@ def process_fields(raw_field) end end -end \ No newline at end of file +end diff --git a/vendor/plugins/acts_as_solr/lib/common_methods.rb b/vendor/plugins/acts_as_solr/lib/common_methods.rb index 39dd022..35841a6 100644 --- a/vendor/plugins/acts_as_solr/lib/common_methods.rb +++ b/vendor/plugins/acts_as_solr/lib/common_methods.rb @@ -6,15 +6,15 @@ module CommonMethods def get_solr_field_type(field_type) if field_type.is_a?(Symbol) case field_type - when :float: return "f" - when :integer: return "i" - when :boolean: return "b" - when :string: return "s" - when :date: return "d" - when :range_float: return "rf" - when :range_integer: return "ri" - when :facet: return "facet" - when :text: return "t" + when :float then return "f" + when :integer then return "i" + when :boolean then return "b" + when :string then return "s" + when :date then return "d" + when :range_float then return "rf" + when :range_integer then return "ri" + when :facet then return "facet" + when :text then return "t" else raise "Unknown field_type symbol: #{field_type}" end @@ -28,10 +28,10 @@ def get_solr_field_type(field_type) # Sets a default value when value being set is nil. def set_value_if_nil(field_type) case field_type - when "b", :boolean: return "false" - when "s", "t", "d", :date, :string, :text: return "" - when "f", "rf", :float, :range_float: return 0.00 - when "i", "ri", :integer, :range_integer: return 0 + when "b", :boolean then return "false" + when "s", "t", "d", :date, :string, :text then return "" + when "f", "rf", :float, :range_float then return 0.00 + when "i", "ri", :integer, :range_integer then return 0 else return "" end @@ -73,4 +73,4 @@ def record_id(object) end -end \ No newline at end of file +end diff --git a/vendor/plugins/acts_as_solr/lib/instance_methods.rb b/vendor/plugins/acts_as_solr/lib/instance_methods.rb index 0941d20..3ff39dd 100644 --- a/vendor/plugins/acts_as_solr/lib/instance_methods.rb +++ b/vendor/plugins/acts_as_solr/lib/instance_methods.rb @@ -120,8 +120,8 @@ def condition_block?(condition) def evaluate_condition(condition, field) case condition - when Symbol: field.send(condition) - when String: eval(condition, binding) + when Symbol then field.send(condition) + when String then eval(condition, binding) else if condition_block?(condition) condition.call(field) @@ -136,4 +136,4 @@ def evaluate_condition(condition, field) end end -end \ No newline at end of file +end