Sha256: 7eaa54b0382444bf23eeaffcfe1528545f030f43be5d4654cbb4a306b5f56e2b

Contents?: true

Size: 809 Bytes

Versions: 1

Compression:

Stored size: 809 Bytes

Contents

# coding: utf-8

module ThinReports
  module Core
    
    # @private
    module Utils
      def in_utf8(&block)
        original = $KCODE
        $KCODE = 'u'
        block.call
      ensure
        $KCODE = original
      end
      
      def block_exec_on(context, &block)
        return context unless block_given?
        
        if block.arity == 1
          block.call(context)
        else
          context.instance_eval(&block)
        end
        context
      end
      
      if RUBY_VERSION < '1.9'
        def ruby_18
          yield
        end
        def ruby_19
          false
        end
      else
        def ruby_18
          false
        end
        def ruby_19
          yield
        end
      end
    end
    
  end
end

# Include global methods.
include ThinReports::Core::Utils

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
thinreports-0.6.0.pre3 lib/thinreports/core/utils.rb