dkubb (owner)

Revisions

gist: 192247 Download_button fork
public
Public Clone URL: git://gist.github.com/192247.git
Embed All Files: show embed
Ruby #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class Account
  include DataMapper::Resource
 
  property :id, Serial
  property :name, String, :nullable => false
 
  repository(:legacy) do
    property :active, Boolean, :nullable => false, :default => true
 
    has n, :billing_terms
  end
end
 
account = Account.get(1)
account.repository.name # => :default
account.active # => raises NoMethodError (in the future)
account.billing_terms # => raises NoMethodError (in the future)
 
repository(:legacy) do
  account = Account.get(1)
  account.repository.name # => :legacy
  account.active # => true
  account.billing_terms # => Collection of BillingTerm objects from legacy repo
end