Class: Ohm::Types::Serialized
Instance Attribute Summary (collapse)
-
- (Object) object
readonly
Returns the value of attribute object.
Instance Method Summary (collapse)
- - (Object) ==(other)
-
- (Serialized) initialize(raw)
constructor
A new instance of Serialized.
- - (Boolean) respond_to?(method)
- - (Object) to_s (also: #inspect)
Methods inherited from Base
Constructor Details
- (Serialized) initialize(raw)
A new instance of Serialized
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/ohm/contrib/typecast.rb', line 139 def initialize(raw) @object = case raw when self.class::RAW raw when ::String begin ::JSON.parse(raw) rescue ::JSON::ParserError raw end when self.class raw.object else ::Kernel.raise ::TypeError, "%s does not accept %s" % [self.class, raw.inspect] end end |
Instance Attribute Details
- (Object) object (readonly)
Returns the value of attribute object
137 138 139 |
# File 'lib/ohm/contrib/typecast.rb', line 137 def object @object end |
Instance Method Details
- (Object) ==(other)
157 158 159 |
# File 'lib/ohm/contrib/typecast.rb', line 157 def ==(other) object == other end |
- (Boolean) respond_to?(method)
166 167 168 |
# File 'lib/ohm/contrib/typecast.rb', line 166 def respond_to?(method) object.respond_to?(method) end |
- (Object) to_s Also known as: inspect
161 162 163 |
# File 'lib/ohm/contrib/typecast.rb', line 161 def to_s object.to_json end |