Sha256: b8cf197b5a883d47736772595de723020ebc5dabf979c5b37642182909c321e4

Contents?: true

Size: 941 Bytes

Versions: 4

Compression:

Stored size: 941 Bytes

Contents

class Planet
  include DataMapper::Resource

  property :name, String, :key => true
  property :aphelion, Float

  # Sorry these associations don't make any sense
  # I just needed a many-to-many association to test against
  has n, :friended_planets
  has n, :friend_planets, :through => :friended_planets, :class_name => 'Planet'

  def category
    case self.name.downcase
    when "mercury", "venus", "earth", "mars" then "terrestrial"
    when "jupiter", "saturn", "uranus", "neptune" then "gas giants"
    when "pluto" then "dwarf planets"
    end
  end

  def has_known_form_of_life?
    self.name.downcase == "earth"
  end
end

class FriendedPlanet
  include DataMapper::Resource

  property :planet_name,        String, :key => true
  property :friend_planet_name, String, :key => true

  belongs_to :planet, :child_key => [:planet_name]
  belongs_to :friend_planet, :class_name => 'Planet', :child_key => [:friend_planet_name]
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dm-serializer-0.9.10 spec/fixtures/planet.rb
dm-serializer-0.9.11 spec/fixtures/planet.rb
dm-serializer-0.9.9 spec/fixtures/planet.rb
dm-serializer-0.9.8 spec/fixtures/planet.rb