Sha256: f101d389a1c025af6104e6a67df2d214a2f50cb7c745edfbfc63e32a9557d4cc

Contents?: true

Size: 730 Bytes

Versions: 3

Compression:

Stored size: 730 Bytes

Contents

module Trailblazer
  class Finder
    # Helper module
    module Utils
      class Extra
        def self.ensure_included(item, collection)
          if collection.include? item
            item
          else
            collection.first
          end
        end

        def self.deep_copy(object)
          case object
          when Array
            object.map { |element| deep_copy(element) }
          when Hash
            object.each_with_object({}) do |(key, value), result|
              result[key] = deep_copy(value)
            end
          when NilClass, FalseClass, TrueClass, Symbol, Method, Numeric
            object
          else
            object.dup
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
trailblazer-finder-0.1.4 lib/trailblazer/finder/utils/extra.rb
trailblazer-finder-0.1.3 lib/trailblazer/finder/utils/extra.rb
trailblazer-finder-0.1.2 lib/trailblazer/finder/utils/extra.rb