Module: Typisch
- Defined in:
- lib/typisch.rb,
lib/typisch/dsl.rb,
lib/typisch/meta.rb,
lib/typisch/null.rb,
lib/typisch/typed.rb,
lib/typisch/union.rb,
lib/typisch/errors.rb,
lib/typisch/string.rb,
lib/typisch/boolean.rb,
lib/typisch/numeric.rb,
lib/typisch/version.rb,
lib/typisch/datetime.rb,
lib/typisch/registry.rb,
lib/typisch/constructor.rb,
lib/typisch/serialization.rb,
lib/typisch/poset_algorithms.rb,
lib/typisch/named_placeholder.rb
Defined Under Namespace
Modules: DSL, Typed Classes: CyclicSerialization, DSLContext, Error, JSONSerializer, NameResolutionError, Registry, SerializationError, Type, TypeDeclarationError, TypedStruct
Constant Summary collapse
Class Method Summary collapse
- .[](name) ⇒ Object
-
.find_minimal_set_of_upper_bounds(*items) ⇒ Object
Finds a minimal set of upper bounds amongst the given set of items from a partially-ordered set, which together cover the whole set.
-
.global_registry ⇒ Object
We set up a global registry which you can use if you like, either via Typisch.global_registry or via the convenience aliases Typisch.[] and Typisch.register.
- .register(&block) ⇒ Object
Class Method Details
.[](name) ⇒ Object
142 143 144 |
# File 'lib/typisch/registry.rb', line 142 def self.[](name) global_registry[name] end |
.find_minimal_set_of_upper_bounds(*items) ⇒ Object
Finds a minimal set of upper bounds amongst the given set of items from a partially-ordered set, which together cover the whole set.
In the worst case this will just return the whole set.
8 9 10 11 12 13 14 15 16 |
# File 'lib/typisch/poset_algorithms.rb', line 8 def find_minimal_set_of_upper_bounds(*items) result = [] items.each do |item| next if result.any? {|other| item <= other} result.delete_if {|other| other <= item} result << item end result end |
.global_registry ⇒ Object
We set up a global registry which you can use if you like, either via Typisch.global_registry or via the convenience aliases Typisch.[] and Typisch.register.
Or, you can make your own registry if you don’t want to share a global registry with other code using this library. (recommended if writing modular code / library code which uses this).
134 135 136 |
# File 'lib/typisch/registry.rb', line 134 def self.global_registry @global_registry ||= Registry.new end |
.register(&block) ⇒ Object
138 139 140 |
# File 'lib/typisch/registry.rb', line 138 def self.register(&block) global_registry.register(&block) end |