Sha256: 698a74e407c1c4c81b79801c1d476712145c0df0418697cea4cbd3d928c7d5ef

Contents?: true

Size: 874 Bytes

Versions: 14

Compression:

Stored size: 874 Bytes

Contents

require "support/memory_model"

module SampleObjects

  class User < MemoryModel

    field :first_name
    field :last_name
    field :age
    field :created_at, default: ->{ Time.now }
    field :updated_at, default: ->{ Time.now }

    has_many :posts
    has_many :comment

  end

  class Post < MemoryModel

    field :body
    field :created_at, default: ->{ Time.now }
    field :updated_at, default: ->{ Time.now }

    has_many :comments
    has_one :rating

  end

  class Comment < MemoryModel

    field :content
    field :created_at, default: ->{ Time.now }
    field :updated_at, default: ->{ Time.now }

    belongs_to :user


  end

  class Rating < MemoryModel

    field :stars, default: -> { Random.rand(1.0..5.0).round(1) }
    field :count, default: -> { Random.rand(20..100) }

    accepts_nested_attributes_for :post

    belongs_to :post

  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
restly-0.0.1.beta.10 spec/support/models.rb
restly-0.0.1.beta.9 spec/support/models.rb
restly-0.0.1.beta.6 spec/support/models.rb
restly-0.0.1.beta.5 spec/support/models.rb
restly-0.0.1.beta.4 spec/support/models.rb
restly-0.0.1.beta.3 spec/support/models.rb
restly-0.0.1.beta.2 spec/support/models.rb
restly-0.0.1.beta.1 spec/support/models.rb
restly-0.0.1.alpha.22 spec/support/models.rb
restly-0.0.1.alpha.19 spec/support/models.rb
restly-0.0.1.alpha.18 spec/support/models.rb
restly-0.0.1.alpha.16 spec/support/models.rb
restly-0.0.1.alpha.12 spec/support/models.rb
restly-0.0.1.alpha.11 spec/support/models.rb