Class: OrangeData::PayloadContent

Inherits:
Object
  • Object
show all
Defined in:
lib/orange_data/generated_attributes.rb

Overview

base class for semi-generated classes

Instance Method Summary collapse

Constructor Details

#initialize(payload = {}) ⇒ PayloadContent

Returns a new instance of PayloadContent.



111
112
113
# File 'lib/orange_data/generated_attributes.rb', line 111

def initialize(payload={})
  @payload = payload
end

Instance Method Details

#==(other) ⇒ Object



128
129
130
131
# File 'lib/orange_data/generated_attributes.rb', line 128

def ==(other)
  self.class == other.class && to_hash == other.to_hash
  # @payload == other.instance_variable_get(:@payload)
end

#as_jsonObject



137
138
139
# File 'lib/orange_data/generated_attributes.rb', line 137

def as_json
  to_hash
end

#assign_attributes(options) ⇒ Object



115
116
117
118
119
120
121
122
# File 'lib/orange_data/generated_attributes.rb', line 115

def assign_attributes(options)
  options.each_pair{|k, v|
    setter = :"#{k}="
    send(setter, v)
  }
  # for chaining:
  self
end

#attributesObject



124
125
126
# File 'lib/orange_data/generated_attributes.rb', line 124

def attributes
  to_hash.map{|(k, v)| [k.underscore, v] }.to_h
end

#to_hashObject



133
134
135
# File 'lib/orange_data/generated_attributes.rb', line 133

def to_hash
  @payload
end

#to_json(*args) ⇒ Object



141
142
143
# File 'lib/orange_data/generated_attributes.rb', line 141

def to_json(*args)
  as_json.to_json(*args)
end