Sha256: 0175db7606a93c7ca3708b60a5a0ffb0a4fc56c17e4ba6b3f5ef9e43060f0310
Contents?: true
Size: 1.54 KB
Versions: 1
Compression:
Stored size: 1.54 KB
Contents
# List of classes to encode mirrors JSON encodable objects in ActiveSupport require 'time' require 'space_object/string_encodable' class Array def to_space_object each_with_index.map do |item, index| {index => item}.to_space_object end end def to_space_value to_space_object end end class Date include SpaceObject::StringEncodable end class DateTime include SpaceObject::StringEncodable end module Enumerable def to_space_object to_a.to_space_object end def to_space_value to_space_object end end class FalseClass include SpaceObject::StringEncodable end class Hash def to_space_object SpaceObject::Encoder.new(self).encode end end class NilClass include SpaceObject::StringEncodable end class Numeric include SpaceObject::StringEncodable end class Object # Highly inspired by ActiveSupport def to_space_object hash = respond_to?(:to_hash) ? to_hash : insance_values hash.to_space_object end def to_space_value to_space_object end end class Process::Status include SpaceObject::StringEncodable end class Regexp include SpaceObject::StringEncodable end class String include SpaceObject::StringEncodable end class Symbol include SpaceObject::StringEncodable end class Struct # Highly inspired by ActiveSupport def to_space_object hash = Hash[members.zip(values)] hash.to_space_object end def to_space_value to_space_object end end class Time include SpaceObject::StringEncodable end class TrueClass include SpaceObject::StringEncodable end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
space_object-0.1.3 | lib/space_object/core_ext/object/space_object.rb |