Class: Manywho::MyStruct
- Inherits:
-
Object
- Object
- Manywho::MyStruct
- Defined in:
- lib/manywho.rb
Overview
Initialized with a JSON hash, each value of the hash is converted into an instance variable. Can also be easily converted into a JSON string
Direct Known Subclasses
AuthorizationContext, AuthorizationRequest, EngineInitializationRequest, EngineInitializationResponse, EngineInvokeRequest, EngineInvokeResponse, EngineValue, FlowIdentifier, FlowResponse, GeoLocation, MapElementInvokeRequest, MapElementInvokeResponse, OutcomeResponse, PageComponentDataResponse, PageComponentResponse, PageContainerDataResponse, PageContainerResponse, PageResponse
Instance Method Summary collapse
-
#initialize(jsonValue) ⇒ MyStruct
constructor
Set instance values from the hash.
- #to_json(options = {}) ⇒ Object
Constructor Details
#initialize(jsonValue) ⇒ MyStruct
Set instance values from the hash
328 329 330 331 332 333 334 |
# File 'lib/manywho.rb', line 328 def initialize(jsonValue) if (jsonValue != nil) jsonValue.each do |k,v| self.instance_variable_set("@#{k}", v) end end end |
Instance Method Details
#to_json(options = {}) ⇒ Object
319 320 321 322 323 324 325 |
# File 'lib/manywho.rb', line 319 def to_json(= {}) hash = {} self.instance_variables.each do |var| hash[var[1...var.length]] = self.instance_variable_get var end return hash.to_json end |