Sha256: 2824009f40714ec61a00f798fb2a6e623d8ef38f7321cd9bf2ff68dd79865afb

Contents?: true

Size: 841 Bytes

Versions: 14

Compression:

Stored size: 841 Bytes

Contents

# -*- coding: utf-8 -*-

module DataMapper
  module Validations
    module Fixtures

      class Event
        #
        # Behaviors
        #

        include ::DataMapper::Resource

        #
        # Properties
        #

        property :id,   Serial
        property :name, String, :required => true

        property :starts_at, DateTime
        property :ends_at,   DateTime

        #
        # Validations
        #

        validates_with_method :starts_at, :method => :ensure_dates_order_is_correct

        #
        # API
        #

        def ensure_dates_order_is_correct
          if starts_at && ends_at && (starts_at <= ends_at)
            true
          else
            [false, "Start time cannot be after end time"]
          end
        end
      end # Event
    end # Fixtures
  end # Validations
end # DataMapper

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
ardm-validations-1.2.0 spec/fixtures/event.rb
dm-validations-1.2.0 spec/fixtures/event.rb
dm-validations-1.2.0.rc2 spec/fixtures/event.rb
dm-validations-1.2.0.rc1 spec/fixtures/event.rb
dm-validations-1.1.0 spec/fixtures/event.rb
dm-validations-1.1.0.rc3 spec/fixtures/event.rb
dm-validations-1.1.0.rc2 spec/fixtures/event.rb
dm-validations-1.1.0.rc1 spec/fixtures/event.rb
dm-validations-1.0.2 spec/fixtures/event.rb
dm-validations-1.0.1 spec/fixtures/event.rb
dm-validations-1.0.0 spec/fixtures/event.rb
dm-validations-1.0.0.rc3 spec/fixtures/event.rb
dm-validations-1.0.0.rc2 spec/fixtures/event.rb
dm-validations-1.0.0.rc1 spec/fixtures/event.rb