Guest User

Untitled

a guest
May 25th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. ## A Patch by Overbryd for acts_as_xapian Range Searching
  2.  
  3. # in lib/acts_as_xapian.rb, at line 597:
  4. # Extract value of a field from the model
  5. def xapian_value(field, type = nil)
  6. value = self[field] || self.send(field.to_sym)
  7. if type == :date
  8. if value.kind_of?(Time)
  9. value.utc.strftime("%Y%m%d")
  10. elsif value.kind_of?(Date)
  11. value.to_time.utc.strftime("%Y%m%d")
  12. else
  13. raise "Only Time or Date types supported by acts_as_xapian for :date fields, got " + value.class.to_s
  14. end
  15. + elsif type == :number
  16. + Xapian::sortable_serialise(value)
  17. elsif type == :boolean
  18. value ? true : false
  19. else
  20. value.to_s
  21. end
  22. end
Add Comment
Please, Sign In to add comment