blob: 0086804c30b43a21bb53246060b8cf5e01765139 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
require 'coupon_code'
class InviteCode < CouchRest::Model::Base
use_database 'invite_codes'
property :invite_code, String, :read_only => true
property :invite_count, Integer, :default => 0, :accessible => true
property :invite_max_uses, Integer, :default => 1, :accessible => true
timestamps!
design do
view :by_invite_code
view :by_invite_count
view :by_invite_max_uses
end
def initialize(attributes = {}, options = {})
super(attributes, options)
write_attribute('invite_code', CouponCode.generate) if new?
end
end
|