Sha256: 44f343608b15fc76e51f52ab00748c4b175d620e6d8b64a1282e9dffaea10b9f

Contents?: true

Size: 789 Bytes

Versions: 5

Compression:

Stored size: 789 Bytes

Contents

# frozen_string_literal: true

module Thinreports
  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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
thinreports-0.12.1 lib/thinreports/core/utils.rb
thinreports-0.12.0 lib/thinreports/core/utils.rb
thinreports-0.11.0 lib/thinreports/core/utils.rb
thinreports-0.10.3 lib/thinreports/core/utils.rb
thinreports-0.10.2 lib/thinreports/core/utils.rb