Sha256: baa8392e01fadf491f9f394f6fd697d3ba215cc3d81d3655b9d521cf15a33509

Contents?: true

Size: 698 Bytes

Versions: 24

Compression:

Stored size: 698 Bytes

Contents

# encoding: utf-8
require "set"

module Origin
  module Extensions

    # This module contains additional object behaviour.
    module Set
      module ClassMethods

        # Evolve the set, casting all its elements.
        #
        # @example Evolve the set.
        #   Set.evolve(set)
        #
        # @param [ Set, Object ] object The object to evolve.
        #
        # @return [ Array ] The evolved set.
        #
        # @since 1.0.0
        def evolve(object)
          return object if !object || !object.respond_to?(:map)
          object.map{ |obj| obj.class.evolve(obj) }
        end
      end
    end
  end
end

::Set.__send__(:extend, Origin::Extensions::Set::ClassMethods)

Version data entries

24 entries across 23 versions & 4 rubygems

Version Path
origin-1.0.3 lib/origin/extensions/set.rb
origin-1.0.2 lib/origin/extensions/set.rb
origin-1.0.1 lib/origin/extensions/set.rb
origin-1.0.0 lib/origin/extensions/set.rb