Sha256: 5f8aa754b391999f91fc04edcebebb2bf91657dcfa54e5a0afaf989f7447c6e6

Contents?: true

Size: 736 Bytes

Versions: 2

Compression:

Stored size: 736 Bytes

Contents

require 'forwardable'

module Twitter
  class NullObject
    extend Forwardable
    def_instance_delegators :nil, :nil?, :to_a, :to_c, :to_c, :to_f, :to_h,
                            :to_i, :to_r, :to_s
    alias_method :to_ary, :to_a
    alias_method :to_str, :to_s

    # @return [Twitter::NullObject] This method always returns self.
    def method_missing(*args, &block)
      self
    end

    # @return [TrueClass] This method always returns true.
    def respond_to?(method_name, include_private = false)
      true
    end if RUBY_VERSION < '1.9'

    # @return [TrueClass] This method always returns true.
    def respond_to_missing?(method_name, include_private = false)
      true
    end if RUBY_VERSION >= '1.9'
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
twitter-5.5.1 lib/twitter/null_object.rb
twitter-5.5.0 lib/twitter/null_object.rb