Sha256: f14a2968eeb588b2e5c360e032d4dbe23875fff282f0d6f341cc2c69082f4482

Contents?: true

Size: 500 Bytes

Versions: 6

Compression:

Stored size: 500 Bytes

Contents

require 'tempfile'
module Jpmobile
  module Util
    module_function
    def deep_apply(obj, &proc)
      case obj
      when Hash
        obj.each_pair do |key, value|
          obj[key] = deep_apply(value, &proc)
        end
      when Array
        obj.collect!{|value| deep_apply(value, &proc)}
      when NilClass, TrueClass, FalseClass, Tempfile, StringIO
        return obj
      else
        obj = obj.to_param if obj.respond_to?(:to_param)
        proc.call(obj)
      end
    end
  end
end

Version data entries

6 entries across 4 versions & 1 rubygems

Version Path
jpmobile-0.0.8 lib/jpmobile/util.rb
jpmobile-0.0.7 test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/util.rb
jpmobile-0.0.7 lib/jpmobile/util.rb
jpmobile-0.0.6 test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/util.rb
jpmobile-0.0.6 lib/jpmobile/util.rb
jpmobile-0.0.4 lib/jpmobile/util.rb