Sha256: 497fb4df9cae9765cc0be98d7defc26b90346ca0f2c0d443c8b7d086d0f833cf

Contents?: true

Size: 1007 Bytes

Versions: 4

Compression:

Stored size: 1007 Bytes

Contents

require 'question'
require 'person'
require 'money'

class Course < CouchRest::Model::Base
  use_database TEST_SERVER.default_database
  
  property :title, String
  property :subtitle, String, :allow_blank => false
  property :questions, [Question]
  property :professor, Person
  property :participants, [Object]
  property :ends_at, Time
  property :estimate, Float
  property :hours, Integer
  property :profit, BigDecimal
  property :started_on, :type => Date
  property :updated_at, DateTime
  property :active, :type => TrueClass
  property :very_active, :type => TrueClass
  property :klass, :type => Class
  property :currency, String, :default => 'EUR'
  property :price, Money
  property :symbol, Symbol

  design do
    view :by_title
    view :by_title_and_active

    view :by_dept, :ducktype => true

    view :by_active, :map => "function(d) { if (d['#{model_type_key}'] == 'Course' && d['active']) { emit(d['updated_at'], 1); }}", :reduce => "function(k,v,r) { return sum(v); }"
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
couchrest_model-2.0.4 spec/fixtures/models/course.rb
couchrest_model-2.0.3 spec/fixtures/models/course.rb
couchrest_model-2.0.1 spec/fixtures/models/course.rb
couchrest_model-2.0.0 spec/fixtures/models/course.rb