Sha256: 8b81013b73d12ae5a89e7f48014b5f54dd226e021ea8f6ef5ef8fd9f03bcb7d6

Contents?: true

Size: 862 Bytes

Versions: 13

Compression:

Stored size: 862 Bytes

Contents

require 'pathname'

root_path = Pathname(__FILE__).dirname.join('..').expand_path
lib_path  = root_path.join('lib')
$:.unshift(lib_path)

require 'toy'
require 'adapter/memory'

class Address
  include Toy::Store
  store :memory, {}

  attribute :city,  String
  attribute :state, String
  attribute :zip,   String

  index :zip
end

class PhoneNumber
  include Toy::Store

  attribute :area_code, String
  attribute :number,    String
end

class Company
  include Toy::Store
  store :memory, {}

  attribute :name, String
end

class User
  include Toy::Store
  store :memory, {}

  attribute :name,  String
  attribute :age,   Integer
  attribute :admin, Boolean, :default => false
  attribute :ssn,   String
  timestamps

  index :ssn

  list :addresses, :dependendent => true
  reference :employer, Company

  # validations and callbacks are available too
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
toystore-0.8.3 examples/models.rb
toystore-0.8.2 examples/models.rb
toystore-0.8.1 examples/models.rb
toystore-0.8.0 examples/models.rb
toystore-0.7.0 examples/models.rb
toystore-0.6.6 examples/models.rb
toystore-0.6.5 examples/models.rb
toystore-0.6.4 examples/models.rb
toystore-0.6.3 examples/models.rb
toystore-0.6.2 examples/models.rb
toystore-0.6.1 examples/models.rb
toystore-0.6 examples/models.rb
toystore-0.5 examples/models.rb