Sha256: f19eef922143a02f74ab1ee18694e31f48674a662a22ea73811eedaa93a1ba20
Contents?: true
Size: 2 KB
Versions: 3
Compression:
Stored size: 2 KB
Contents
# # ActiveFacts Runtime API # Standard types extensions. # # Copyright (c) 2009 Clifford Heath. Read the LICENSE file. # # These extensions add ActiveFacts Concept and Instance behaviour into base Ruby value classes, # and allow any Class to become an Entity. # 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 # Make this Class into a Concept and if necessary its module into a Vocabulary. # The parameters are the names (Symbols) of the identifying roles. def identified_by *args raise "#{basename} is 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 def is_entity_type respond_to?(:identifying_role_names) end end # REVISIT: Fix these NORMA types class Decimal < Int #:nodoc: end class SignedInteger < Int #:nodoc: end class SignedSmallInteger < Int #:nodoc: end class SignedTinyInteger < Int #:nodoc: end class UnsignedInteger < Int #:nodoc: end class UnsignedSmallInteger < Int #:nodoc: end class UnsignedTinyInteger < 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
activefacts-0.8.6 | lib/activefacts/api/standard_types.rb |
activefacts-0.8.5 | lib/activefacts/api/standard_types.rb |
activefacts-0.7.3 | lib/activefacts/api/standard_types.rb |