Class: EwayRapid::InternalModels::Option

Inherits:
Object
  • Object
show all
Defined in:
lib/eway_rapid/models/internal_models.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#valueObject

Returns the value of attribute value.



147
148
149
# File 'lib/eway_rapid/models/internal_models.rb', line 147

def value
  @value
end

Class Method Details

.from_array(array) ⇒ Object



181
182
183
184
185
186
187
188
# File 'lib/eway_rapid/models/internal_models.rb', line 181

def self.from_array(array)
  options = []
  array.each {|option_hash|
    obj = Option.from_hash(option_hash)
    options.push(obj)
  }
  options
end

.from_hash(hash) ⇒ Object



175
176
177
178
179
# File 'lib/eway_rapid/models/internal_models.rb', line 175

def self.from_hash(hash)
  option = Option.new
  option.value = hash[Constants::VALUE]
  option
end

.from_json(json) ⇒ Object



170
171
172
173
# File 'lib/eway_rapid/models/internal_models.rb', line 170

def self.from_json(json)
  hash = JSON.parse(json)
  from_hash(hash)
end

.to_array(array) ⇒ Object



157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/eway_rapid/models/internal_models.rb', line 157

def self.to_array(array)
  options = []
  if array
    array.each {|option_hash|
      if option_hash
        obj = Option.to_hash(option_hash)
        options.push(obj)
      end
    }
  end
  options
end

.to_hash(option) ⇒ Object



149
150
151
152
153
154
155
# File 'lib/eway_rapid/models/internal_models.rb', line 149

def self.to_hash(option)
  hash = {}
  if option
    hash[Constants::VALUE] = option.value if option.value
  end
  hash
end