Class: ActiveFacts::Metamodel::DataType::Context
- Inherits:
-
Object
- Object
- ActiveFacts::Metamodel::DataType::Context
- Defined in:
- lib/activefacts/metamodel/datatypes.rb
Overview
A DataType Context class should refine this class. The default context might work for you.
Direct Known Subclasses
Instance Method Summary collapse
- #boolean_type ⇒ Object
- #choose_integer_range(min, max) ⇒ Object
- #default_length(data_type, type_name) ⇒ Object
-
#initialize(options = {}) ⇒ Context
constructor
A new instance of Context.
- #integer_ranges ⇒ Object
- #surrogate_type ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Context
Returns a new instance of Context.
66 67 68 |
# File 'lib/activefacts/metamodel/datatypes.rb', line 66 def initialize = {} raise "Unused options in DataType::Context: #{.inspect}" unless .empty? end |
Instance Method Details
#boolean_type ⇒ Object
82 83 |
# File 'lib/activefacts/metamodel/datatypes.rb', line 82 def boolean_type end |
#choose_integer_range(min, max) ⇒ Object
76 77 78 79 80 |
# File 'lib/activefacts/metamodel/datatypes.rb', line 76 def choose_integer_range min, max integer_ranges. select{|type_name, vmin, vmax| min >= vmin && max <= vmax}. sort_by{|type_name, vmin, vmax| vmax-vmin}[0] # Choose the smallest range end |
#default_length(data_type, type_name) ⇒ Object
73 74 |
# File 'lib/activefacts/metamodel/datatypes.rb', line 73 def default_length data_type, type_name end |
#integer_ranges ⇒ Object
70 71 |
# File 'lib/activefacts/metamodel/datatypes.rb', line 70 def integer_ranges end |
#surrogate_type ⇒ Object
85 86 |
# File 'lib/activefacts/metamodel/datatypes.rb', line 85 def surrogate_type end |