Sha256: 916f40a997837d6e78e3ef22be203f4cf279609b5d39f7708d68bae52c57518d

Contents?: true

Size: 1.74 KB

Versions: 2

Compression:

Stored size: 1.74 KB

Contents

require 'rubygems'
require 'active_support/core_ext/symbol'
require 'active_support/core_ext/blank'
require 'active_support/core_ext/duplicable'
require 'active_support/core_ext/array/extract_options'

class Array #:nodoc:
  include ActiveSupport::CoreExtensions::Array::ExtractOptions
end

require 'active_support/core_ext/hash/reverse_merge'
require 'active_support/core_ext/module/delegation'
require 'active_support/core_ext/module/aliasing'
require 'active_support/core_ext/module/attribute_accessors'
require 'active_support/core_ext/object/misc' # returning
require 'active_support/inflector'
require 'active_support/multibyte'
require 'active_support/core_ext/string'
class String
  # This conflicts with builder, unless builder is required first, which we don't want to force on people
  undef_method :to_xs if method_defined?(:to_xs)
end

require 'extensions/enumerable'
require 'extensions/array'

class Module #:nodoc:
  include ActiveSupport::CoreExtensions::Module if ActiveSupport::CoreExtensions.const_defined? :Module
end

class Hash #:nodoc:
  include ActiveSupport::CoreExtensions::Hash::ReverseMerge
end

class Object #:nodoc:
  unless method_defined?(:try)
    # Taken from the upcoming ActiveSupport 2.3
    #
    # Tries to send the method only if object responds to it. Return +nil+ otherwise.
    # It will also forward any arguments and/or block like Object#send does.
    #
    # ==== Example :
    #
    # # Without try
    # @person ? @person.name : nil
    #
    # With try
    # @person.try(:name)
    #
    # # try also accepts arguments/blocks for the method it is trying
    # Person.try(:find, 1)
    # @people.try(:map) {|p| p.name}
    def try(method, *args, &block)
      send(method, *args, &block) if respond_to?(method, true)
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
Empact-roxml-2.4.0 lib/roxml/extensions/active_support.rb
roxml-2.4.0 lib/roxml/extensions/active_support.rb