Sha256: 061ecb712494b5cdeeab1c9066311470716031a22aeaca415e1571847b1e4dae
Contents?: true
Size: 727 Bytes
Versions: 28
Compression:
Stored size: 727 Bytes
Contents
class Object def rson? false end end [ FalseClass, TrueClass, Numeric, String, Symbol, NilClass, ].each do |klass| klass.class_eval do def to_rson options = {} self end def rson? true end end end Array.class_eval do def to_rson options = {} collect{|v| v.to_rson(options)} end def rson? all?{|v| v.rson?} end end [Hash, OpenObject].each do |klass| klass.class_eval do def to_rson options = {} r = self.class.new each do |k, v| r[k.to_rson(options)] = v.to_rson(options) end r end def rson? each do |k, v| return false unless k.rson? and v.rson? end true end end end
Version data entries
28 entries across 28 versions & 3 rubygems