Skip to content

Commit

Permalink
Fix "acts_as_solr" to work with Ruby 1.9.2.
Browse files Browse the repository at this point in the history
  • Loading branch information
igal committed Oct 17, 2011
1 parent 4586301 commit 181f03b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions vendor/plugins/acts_as_solr/lib/acts_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -169,4 +169,4 @@ def process_fields(raw_field)
end

end
end
end
28 changes: 14 additions & 14 deletions vendor/plugins/acts_as_solr/lib/common_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -73,4 +73,4 @@ def record_id(object)

end

end
end
6 changes: 3 additions & 3 deletions vendor/plugins/acts_as_solr/lib/instance_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -136,4 +136,4 @@ def evaluate_condition(condition, field)
end

end
end
end

0 comments on commit 181f03b

Please sign in to comment.