Sha256: d3504056e9f837e45e79ac022bf837df5ee7d69bbe3c90b29629a207a0339724

Contents?: true

Size: 1.03 KB

Versions: 4

Compression:

Stored size: 1.03 KB

Contents

# This is for adding specific methods that are required by sinatra_more if activesupport isn't required

unless String.method_defined?(:titleize)
  require 'active_support/inflector'
  require 'active_support/core_ext/blank'
end

unless Hash.method_defined?(:reverse_merge!)
  module HashExtensions
    def reverse_merge(other_hash)
      other_hash.merge(self)
    end
    def reverse_merge!(other_hash)
      replace(reverse_merge(other_hash))
    end
  end
end

unless Hash.method_defined?(:symbolize_keys!)
  module HashExtensions
    def symbolize_keys
      inject({}) do |options, (key, value)|
        options[(key.to_sym rescue key) || key] = value
        options
      end
    end
    def symbolize_keys!
      self.replace(self.symbolize_keys)
    end
  end
end

unless Array.method_defined?(:extract_options!)
  module ArrayExtensions
    def extract_options!
      last.is_a?(::Hash) ? pop : {}
    end
  end
end

Hash.send(:include, HashExtensions) if defined?(HashExtensions)
Array.send(:include, ArrayExtensions) if defined?(ArrayExtensions)

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sinatra_more-0.2.4 lib/sinatra_more/support_lite.rb
sinatra_more-0.2.3 lib/sinatra_more/support_lite.rb
sinatra_more-0.2.2 lib/sinatra_more/support_lite.rb
sinatra_more-0.2.1 lib/sinatra_more/support_lite.rb