spec/models/address.rb in mongoid-eager-loading-0.2.0 vs spec/models/address.rb in mongoid-eager-loading-0.3.0
- old
+ new
@@ -13,28 +13,35 @@
field :services, :type => Array
field :latlng, :type => Array
key :street
embeds_many :locations
- embedded_in :addressable, :inverse_of => :addresses do
+ embedded_in :addressable, :polymorphic => true do
def extension
"Testing"
end
def doctor?
title == "Dr"
end
end
+ referenced_in :account
+
named_scope :rodeo, where(:street => "Rodeo Dr") do
def mansion?
all? { |address| address.street == "Rodeo Dr" }
end
end
validates_presence_of :street, :on => :update
+ validates_format_of :street, :with => /\D/, :allow_nil => true
def set_parent=(set = false)
self.parent_title = addressable.title if set
+ end
+
+ def <=>(other)
+ street <=> other.street
end
class << self
def california
where(:state => "CA")