Sha256: 76e924481f679013782cc9e593a5e4f5aee2c5599b52bae05c423d1ce75c7509

Contents?: true

Size: 1.62 KB

Versions: 2

Compression:

Stored size: 1.62 KB

Contents

#
# The ActiveFacts Runtime API Standard types extensions.
# Copyright (c) 2008 Clifford Heath. Read the LICENSE file.
#
# These extensions add ActiveFacts Concept and Instance behaviour into base Ruby classes.
#
require 'date'

module ActiveFacts
  module API
    # Adapter module to add value_type to all potential value classes
    module ValueClass #:nodoc:
      def value_type *args, &block #:nodoc:
        include ActiveFacts::API::Value
        # the included method adds the Value::ClassMethods
        initialise_value_type(*args, &block)
      end
    end
  end
end

require 'activefacts/api/numeric'

# Add the methods that convert our classes into Concept types:

ValueClasses = [String, Date, DateTime, Time, Int, Real, AutoCounter]
ValueClasses.each{|c|
    c.send :extend, ActiveFacts::API::ValueClass
  }

class TrueClass #:nodoc:
  def verbalise(role_name = nil); role_name ? "#{role_name}: true" : "true"; end
end

class NilClass #:nodoc:
  def verbalise; "nil"; end
end

class Class
  def identified_by *args
    raise "not an entity type" if respond_to? :value_type  # Don't make a ValueType into an EntityType
    include ActiveFacts::API::Entity
    initialise_entity_type(*args)
  end
end

# REVISIT: Fix these NORMA types
class Decimal < Int #:nodoc:
end
class SignedInteger < Int #:nodoc:
end
class SignedSmallInteger < Int #:nodoc:
end
class UnsignedInteger < Int #:nodoc:
end
class UnsignedSmallInteger < Int #:nodoc:
end
class LargeLengthText < String #:nodoc:
end
class FixedLengthText < String #:nodoc:
end
class PictureRawData < String #:nodoc:
end
class DateAndTime < DateTime #:nodoc:
end
class Money < Decimal #:nodoc:
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
activefacts-0.6.0 lib/activefacts/api/standard_types.rb
activefacts-0.7.0 lib/activefacts/api/standard_types.rb