Sha256: b7718c3ef22ad0db99831eeff1d7d908683c2305aa3ef747c26b4e7616dc012f

Contents?: true

Size: 889 Bytes

Versions: 1

Compression:

Stored size: 889 Bytes

Contents

# frozen_string_literal: true

module LedgerSync
  module Util
    module Mixins
      module DelegateIterableMethodsMixin
        module ClassMethods
          SHARED_METHODS = %i[
            []
            any?
            count
            each
            empty?
            include?
            map
          ].freeze

          ARRAY_METHODS = (SHARED_METHODS | %i[]).freeze

          HASH_METHODS = (SHARED_METHODS | %i[
            each_value
            key?
            keys
            values
          ]).freeze

          def delegate_array_methods_to(delegate_to)
            delegate(*ARRAY_METHODS, to: delegate_to)
          end

          def delegate_hash_methods_to(delegate_to)
            delegate(*HASH_METHODS, to: delegate_to)
          end
        end

        def self.included(base)
          base.extend(ClassMethods)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ledger_sync-1.3.5 lib/ledger_sync/util/mixins/delegate_iterable_methods_mixin.rb