Sha256: 022a24aae64269715acbb938b7e2efca0874810573621c0bd501ec52e7575ec1

Contents?: true

Size: 980 Bytes

Versions: 1

Compression:

Stored size: 980 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

  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

1 entries across 1 versions & 1 rubygems

Version Path
couchrest_model-2.0.0.beta2 spec/fixtures/models/course.rb