Sha256: 7d0c63e8beb0b4daf6c0e2fb9a6944b4deb3a911f41e46f8298197414de89a5f

Contents?: true

Size: 726 Bytes

Versions: 5

Compression:

Stored size: 726 Bytes

Contents

# coding: utf-8

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

    def deep_copy(src)
      case src
      when Hash
        src.inject({}) {|h, (k, v)| h[k] = (v.dup rescue v); h }
      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

5 entries across 5 versions & 1 rubygems

Version Path
thinreports-0.9.1 lib/thinreports/core/utils.rb
thinreports-0.9.0 lib/thinreports/core/utils.rb
thinreports-0.8.2 lib/thinreports/core/utils.rb
thinreports-0.8.1 lib/thinreports/core/utils.rb
thinreports-0.8.0 lib/thinreports/core/utils.rb