Refactored basic directory structure. Moved to ActiveSupport for Validations and Callbacks. Cleaned up older code, and removed support for text property types.
32 lines
936 B
Ruby
32 lines
936 B
Ruby
# This file contains various hacks for Rails compatibility.
|
|
class Hash
|
|
# Hack so that CouchRest::Document, which descends from Hash,
|
|
# doesn't appear to Rails routing as a Hash of options
|
|
def self.===(other)
|
|
return false if self == Hash && other.is_a?(CouchRest::Document)
|
|
super
|
|
end
|
|
end
|
|
|
|
CouchRest::Document.class_eval do
|
|
# Need this when passing doc to a resourceful route
|
|
alias_method :to_param, :id
|
|
|
|
# Hack so that CouchRest::Document, which descends from Hash,
|
|
# doesn't appear to Rails routing as a Hash of options
|
|
def is_a?(o)
|
|
return false if o == Hash
|
|
super
|
|
end
|
|
alias_method :kind_of?, :is_a?
|
|
end
|
|
|
|
CouchRest::Model::CastedModel.class_eval do
|
|
# The to_param method is needed for rails to generate resourceful routes.
|
|
# In your controller, remember that it's actually the id of the document.
|
|
def id
|
|
return nil if base_doc.nil?
|
|
base_doc.id
|
|
end
|
|
alias_method :to_param, :id
|
|
end
|