Sha256: 99666ca74ce1d16ab104978f373d11d3fb797c4903e2e60a5339bd6bcfa44206

Contents?: true

Size: 689 Bytes

Versions: 1

Compression:

Stored size: 689 Bytes

Contents

class Address
  include Mongoid::Document
  field :address_type
  field :number, :type => Integer
  field :street
  field :city
  field :state
  field :post_code
  field :parent_title
  field :services, :type => Array
  key :street
  embeds_many :locations

  embedded_in :addressable, :inverse_of => :addresses do
    def extension
      "Testing"
    end
    def doctor?
      title == "Dr"
    end
  end

  named_scope :rodeo, where(:street => "Rodeo Dr")

  def set_parent=(set = false)
    self.parent_title = addressable.title if set
  end

  class << self
    def california
      where(:state => "CA")
    end

    def homes
      where(:address_type => "Home")
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mongoid-pre-2.0.0.beta1 spec/models/address.rb