Sha256: 8a87647f9a2f6dccd27337449eabade8f079f2e0ef1f719bb99178d304f02663

Contents?: true

Size: 1.14 KB

Versions: 13

Compression:

Stored size: 1.14 KB

Contents

begin
  require 'active_support/core_ext/hash/keys'
  require 'active_support/core_ext/hash/deep_merge'
rescue LoadError
  class Hash
    def stringify_keys
      keys.each do |key|
        self[key.to_s] = delete(key)
      end
      self
    end if !{}.respond_to?(:stringify_keys)

    def symbolize_keys
      keys.each do |key|
        self[(key.to_sym rescue key) || key] = delete(key)
      end
      self
    end if !{}.respond_to?(:symbolize_keys)

    def deep_symbolize_keys
      keys.each do |key|
        value = delete(key)
        self[(key.to_sym rescue key) || key] = value

        value.deep_symbolize_keys if value.is_a? Hash
      end
      self
    end if !{}.respond_to?(:deep_symbolize_keys)
  end
end

begin
  require 'active_support/core_ext/string/inflections'
rescue LoadError
  class String
    def constantize
      names = self.split('::')
      names.shift if names.empty? || names.first.empty?

      constant = Object
      names.each do |name|
        constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
      end
      constant
    end
  end if !"".respond_to?(:constantize)
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
shoryuken-2.0.3 lib/shoryuken/core_ext.rb
shoryuken-2.0.2 lib/shoryuken/core_ext.rb
shoryuken-2.0.1 lib/shoryuken/core_ext.rb
shoryuken-2.0.0 lib/shoryuken/core_ext.rb
shoryuken-1.0.3 lib/shoryuken/core_ext.rb
shoryuken-1.0.2 lib/shoryuken/core_ext.rb
shoryuken-1.0.1 lib/shoryuken/core_ext.rb
shoryuken-1.0.0 lib/shoryuken/core_ext.rb
shoryuken-0.0.5 lib/shoryuken/core_ext.rb
shoryuken-0.0.4 lib/shoryuken/core_ext.rb
shoryuken-0.0.3 lib/shoryuken/core_ext.rb
shoryuken-0.0.2 lib/shoryuken/core_ext.rb
shoryuken-0.0.1 lib/shoryuken/core_ext.rb