Module: Crystalline::Utils
- Defined in:
- lib/crystalline/utils.rb
Class Method Summary collapse
- .arr?(t) ⇒ Boolean
- .arr_of(t) ⇒ Object
- .get_union_types(t) ⇒ Object
- .hash?(t) ⇒ Boolean
- .hash_of(t) ⇒ Object
- .nilable?(t) ⇒ Boolean
- .nilable_of(t) ⇒ Object
- .union?(t) ⇒ Boolean
Class Method Details
.arr?(t) ⇒ Boolean
8 9 10 11 12 13 |
# File 'lib/crystalline/utils.rb', line 8 def self.arr?(t) if t.instance_of? Crystalline::Array return true end false end |
.arr_of(t) ⇒ Object
15 16 17 |
# File 'lib/crystalline/utils.rb', line 15 def self.arr_of(t) t.inner_type end |
.get_union_types(t) ⇒ Object
52 53 54 |
# File 'lib/crystalline/utils.rb', line 52 def self.get_union_types(t) t.types end |
.hash?(t) ⇒ Boolean
19 20 21 22 23 24 |
# File 'lib/crystalline/utils.rb', line 19 def self.hash?(t) if t.instance_of? Crystalline::Hash return true end false end |
.hash_of(t) ⇒ Object
26 27 28 |
# File 'lib/crystalline/utils.rb', line 26 def self.hash_of(t) t.value_type end |
.nilable?(t) ⇒ Boolean
30 31 32 33 34 35 36 37 38 |
# File 'lib/crystalline/utils.rb', line 30 def self.nilable?(t) if t.instance_of? Crystalline::Nilable return true end if t.instance_of? Crystalline::Union return t.types.any? { |tt| tt.instance_of? Crystalline::Nilable } end false end |
.nilable_of(t) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/crystalline/utils.rb', line 40 def self.nilable_of(t) if nilable? t return t.inner_type end nil end |
.union?(t) ⇒ Boolean
48 49 50 |
# File 'lib/crystalline/utils.rb', line 48 def self.union?(t) return t.instance_of? Crystalline::Union end |