Module: Dieses::Support::Const
- Included in:
- Dieses
- Defined in:
- lib/dieses/support/const.rb
Constant Summary collapse
- EMPTY_ARRAY =
An empty array
[].freeze
- EMPTY_HASH =
An empty hash
{}.freeze
- EMPTY_OPTS =
An empty list of options
{}.freeze
- EMPTY_SET =
An empty set
::Set.new.freeze
- EMPTY_STRING =
An empty string
''
- IDENTITY =
Identity function
(->(x) { x }).freeze
- Undefined =
rubocop:disable Metrics/BlockLength
Object.new.tap do |undefined| # rubocop:disable Metrics/BlockLength const_set(:Self, -> { Undefined }) def undefined.to_s 'Undefined' end def undefined.inspect 'Undefined' end def undefined.default(x, y = self) if equal?(x) if equal?(y) yield else y end else x end end def undefined.map(value) if equal?(value) self else yield(value) end end def undefined.dup self end def undefined.clone self end def undefined.coalesce(*args) args.find(Self) { |x| !equal?(x) } end end.freeze
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/dieses/support/const.rb', line 67 def self.included(base) super constants.each do |const_name| base.const_set(const_name, const_get(const_name)) end end |