Sha256: 54027060c9043422b2923b208685178e2badd0e399f8c140038db1f08a73318b

Contents?: true

Size: 1.09 KB

Versions: 14

Compression:

Stored size: 1.09 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'
  require 'active_support/core_ext/class/attribute_accessors'
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

14 entries across 14 versions & 1 rubygems

Version Path
sinatra_more-0.3.9 lib/sinatra_more/support_lite.rb
sinatra_more-0.3.8 lib/sinatra_more/support_lite.rb
sinatra_more-0.3.7 lib/sinatra_more/support_lite.rb
sinatra_more-0.3.6 lib/sinatra_more/support_lite.rb
sinatra_more-0.3.5 lib/sinatra_more/support_lite.rb
sinatra_more-0.3.4 lib/sinatra_more/support_lite.rb
sinatra_more-0.3.3 lib/sinatra_more/support_lite.rb
sinatra_more-0.3.2 lib/sinatra_more/support_lite.rb
sinatra_more-0.3.1 lib/sinatra_more/support_lite.rb
sinatra_more-0.3.0 lib/sinatra_more/support_lite.rb
sinatra_more-0.2.9 lib/sinatra_more/support_lite.rb
sinatra_more-0.2.8 lib/sinatra_more/support_lite.rb
sinatra_more-0.2.7 lib/sinatra_more/support_lite.rb
sinatra_more-0.2.5 lib/sinatra_more/support_lite.rb