Sha256: 6b8650a5a0ddb0fd1e70fab83058b88f6e9f6171caf73c1f5bdca964bc1e67e3

Contents?: true

Size: 722 Bytes

Versions: 6

Compression:

Stored size: 722 Bytes

Contents

class Model
  include Mongocore::Document

  # Just define a validate method and call it when needed
  # Use the errors hash to add your errors to it
  validate do
    errors[:duration] << 'duration must be greater than 0' if duration and duration < 1
    errors[:goal] << 'you need a higher goal' if goal and goal < 5
  end

  attr_accessor :list

  before :save do
    (@list ||= []) << 'before_save'
  end

  before :delete do
    (@list ||= []) << 'before_delete'
  end

  after :save do
    (@list ||= []) << 'after_save'
  end

  after :delete do
    (@list ||= []) << 'after_delete'
  end

  # Save, delete
  # before :delete, :hello
  # after(:delete){ puts "Hello" }

  # def hello
  #   puts "HELLO"
  # end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mongocore-0.5.1 models/model.rb
mongocore-0.5.0 models/model.rb
mongocore-0.4.5 models/model.rb
mongocore-0.4.4 models/model.rb
mongocore-0.4.3 models/model.rb
mongocore-0.4.2 models/model.rb