Sha256: 310e8761310a0f703a790868cee855db9bbf18c9a147f6349797a23322be9112

Contents?: true

Size: 912 Bytes

Versions: 3

Compression:

Stored size: 912 Bytes

Contents

module DataMapper
  module Validations
    module Fixtures
      class Currency

        #
        # Behaviors
        #

        include DataMapper::Resource

        #
        # Properties
        #

        without_auto_validations do
          property :name,   String, :length => 1..50, :key => true
          property :code,   String, :length => 3,     :unique_index => true
          property :symbol, String, :length => 1
        end

        #
        # Validations
        #

        validates_length_of :name,   :within => 1..50
        validates_length_of :code,   :is => 3
        validates_length_of :symbol, :is => 1

        def self.valid_instance(overrides = {})
          defaults = {
            :name   => 'United States Dollar',
            :code   => 'USD',
            :symbol => '$'
          }

          new(defaults.merge(overrides))
        end
      end # Barcode
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dm-validations-1.0.0.rc3 spec/fixtures/currency.rb
dm-validations-1.0.0.rc2 spec/fixtures/currency.rb
dm-validations-1.0.0.rc1 spec/fixtures/currency.rb