Sha256: e2c7f5bdf0b3be5705c18364ba4b09b5ff88a446391e9ed39b8e6510ecd5c8de
Contents?: true
Size: 881 Bytes
Versions: 2
Compression:
Stored size: 881 Bytes
Contents
require 'naught' module Twitter NullObject = Naught.build do |config| include Comparable config.black_hole config.define_explicit_conversions config.define_implicit_conversions config.predicates_return false def ! true end def respond_to?(*) true end def instance_of?(klass) raise(TypeError.new('class or module required')) unless klass.is_a?(Class) self.class == klass end def kind_of?(mod) raise(TypeError.new('class or module required')) unless mod.is_a?(Module) self.class.ancestors.include?(mod) end alias_method :is_a?, :kind_of? def <=>(other) if other.is_a?(self.class) 0 else -1 end end def nil? true end def as_json(*) 'null' end def to_json(*args) nil.to_json(*args) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
twitter-6.1.0 | lib/twitter/null_object.rb |
twitter-6.0.0 | lib/twitter/null_object.rb |