Sha256: afbf16f228c120da31a27fe03f332c30ddd696ca72f9ff37abf75559f16a7a48

Contents?: true

Size: 790 Bytes

Versions: 1

Compression:

Stored size: 790 Bytes

Contents

# frozen_string_literal: true

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

    # rubocop:disable Style/RescueModifier
    def deep_copy(src)
      case src
      when Hash
        src.each_with_object({}) { |(k, v), h| h[k] = v.dup rescue v }
      when Array
        src.map { |a| a.dup rescue a }
      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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
thinreports-0.10.0 lib/thinreports/core/utils.rb