Sha256: 8e42f733f96575d42248b1fae3180637f0761371acd0f9d41e292fd342aa6666

Contents?: true

Size: 982 Bytes

Versions: 5

Compression:

Stored size: 982 Bytes

Contents

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

class Course < CouchRest::Model::Base
  use_database DB 
  
  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

5 entries across 5 versions & 1 rubygems

Version Path
couchrest_model-2.2.0.beta2 spec/fixtures/models/course.rb
couchrest_model-2.2.0.beta1 spec/fixtures/models/course.rb
couchrest_model-2.1.0.rc1 spec/fixtures/models/course.rb
couchrest_model-2.1.0.beta2 spec/fixtures/models/course.rb
couchrest_model-2.1.0.beta1 spec/fixtures/models/course.rb