lib/couchrest/model/casted_model.rb in couchrest_model-1.1.0.beta3 vs lib/couchrest/model/casted_model.rb in couchrest_model-1.1.0.beta4
- old
+ new
@@ -1,47 +1,45 @@
module CouchRest::Model
module CastedModel
-
+
extend ActiveSupport::Concern
included do
include CouchRest::Model::Configuration
include CouchRest::Model::Callbacks
include CouchRest::Model::Properties
include CouchRest::Model::PropertyProtection
include CouchRest::Model::Associations
include CouchRest::Model::Validations
+ include CouchRest::Model::CastedBy
include CouchRest::Model::Dirty
- # attr_accessor :casted_by
+ class_eval do
+ # Override CastedBy's base_doc?
+ def base_doc?
+ false # Can never be base doc!
+ end
+ end
end
def initialize(keys = {})
raise StandardError unless self.is_a? Hash
prepare_all_attributes(keys)
super()
end
def []= key, value
- couchrest_attribute_will_change!(key) if self[key] != value
super(key.to_s, value)
end
def [] key
super(key.to_s)
end
- # Gets a reference to the top level extended
- # document that a model is saved inside of
- def base_doc
- return nil unless @casted_by
- @casted_by.base_doc
- end
-
# False if the casted model has already
# been saved in the containing document
def new?
- @casted_by.nil? ? true : @casted_by.new?
+ casted_by.nil? ? true : casted_by.new?
end
alias :new_record? :new?
def persisted?
!new?
@@ -66,6 +64,7 @@
end
end
alias :attributes= :update_attributes_without_saving
end
+
end