Sha256: dd4facf0c9c06df460026ac8e631f1aa44d4f2e817703b3ffb0d35c5053c7335

Contents?: true

Size: 888 Bytes

Versions: 5

Compression:

Stored size: 888 Bytes

Contents

# frozen_string_literal: true

module Thinreports
  module BasicReport
    module Utils
      def self.included(klass)
        klass.extend self
      end

      def deep_copy(src)
        case src
        when Hash
          src.each_with_object({}) do |(k, v), h|
            h[k] = v.dup rescue v
          end
        when Array
          src.map do |a|
            a.dup rescue a
          end
        else
          raise ArgumentError
        end
      end

      def blank_value?(value)
        case value
        when String   then value.empty?
        when NilClass then true
        else false
        end
      end

      def call_block_in(scope, &block)
        return scope unless block_given?

        if block.arity == 1
          block.call(scope)
        else
          scope.instance_eval(&block)
        end
        scope
      end
    end

    extend Utils
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
thinreports-0.14.2 lib/thinreports/basic_report/core/utils.rb
thinreports-0.14.1 lib/thinreports/basic_report/core/utils.rb
thinreports-0.14.0 lib/thinreports/basic_report/core/utils.rb
thinreports-0.13.1 lib/thinreports/basic_report/core/utils.rb
thinreports-0.13.0 lib/thinreports/basic_report/core/utils.rb