Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## A Patch by Overbryd for acts_as_xapian Range Searching
- # in lib/acts_as_xapian.rb, at line 597:
- # Extract value of a field from the model
- def xapian_value(field, type = nil)
- value = self[field] || self.send(field.to_sym)
- if type == :date
- if value.kind_of?(Time)
- value.utc.strftime("%Y%m%d")
- elsif value.kind_of?(Date)
- value.to_time.utc.strftime("%Y%m%d")
- else
- raise "Only Time or Date types supported by acts_as_xapian for :date fields, got " + value.class.to_s
- end
- + elsif type == :number
- + Xapian::sortable_serialise(value)
- elsif type == :boolean
- value ? true : false
- else
- value.to_s
- end
- end
Add Comment
Please, Sign In to add comment