Module: Kind::BasicObject
Instance Method Summary collapse
- #[](value, label: nil) ⇒ Object
- #or(fallback, value = UNDEFINED) ⇒ Object
- #or_nil(value) ⇒ Object
-
#or_null(value) ⇒ Object
:nodoc:.
- #or_undefined(value) ⇒ Object
- #value(arg, default:) ⇒ Object
- #value?(value = UNDEFINED) ⇒ Boolean
Instance Method Details
#[](value, label: nil) ⇒ Object
5 6 7 |
# File 'lib/kind/objects/basic_object.rb', line 5 def [](value, label: nil) STRICT.object_is_a(self, value, label) end |
#or(fallback, value = UNDEFINED) ⇒ Object
17 18 19 20 21 |
# File 'lib/kind/objects/basic_object.rb', line 17 def or(fallback, value = UNDEFINED) return __or_func.(fallback) if UNDEFINED === value self === value ? value : fallback end |
#or_nil(value) ⇒ Object
9 10 11 |
# File 'lib/kind/objects/basic_object.rb', line 9 def or_nil(value) return value if self === value end |
#or_null(value) ⇒ Object
:nodoc:
33 34 35 |
# File 'lib/kind/objects/basic_object.rb', line 33 def or_null(value) # :nodoc: KIND.nil_or_undefined?(value) ? value : self[value] end |
#or_undefined(value) ⇒ Object
13 14 15 |
# File 'lib/kind/objects/basic_object.rb', line 13 def or_undefined(value) or_nil(value) || Undefined end |
#value(arg, default:) ⇒ Object
29 30 31 |
# File 'lib/kind/objects/basic_object.rb', line 29 def value(arg, default:) KIND.value(self, arg, self[default]) end |
#value?(value = UNDEFINED) ⇒ Boolean
23 24 25 26 27 |
# File 'lib/kind/objects/basic_object.rb', line 23 def value?(value = UNDEFINED) return self === value if UNDEFINED != value @__is_value ||= ->(tc) { ->(arg) { tc === arg } }.(self) end |